I have recently build and launch one monitoring web app in my current company. which to monitor our internal test and services running on different environment. I have build the app on go(golang) which I have really enjoyed to work. This is the technology stack I used:
- Gorrila (rest api)
- chart libraries(d3.js, crossfilter.js and dc.js)
This is my first web app for which I used docker to launch on ECS. it’s running currently on our ECS instance without any issue. I went through some learning process to figure out, how to launch the app on docker. Anyway, I am writing the steps, I followed while launching through docker; May be it will help someone to launch using docker.
- First Step: Create the Dockerfile
There could be different ways do build the dockerfile, I created following Dockerfile:
Please Note: Just make sure you write this file into your project root directory:
FROM golang:latest # update debian packages RUN apt-get update RUN apt-get -y upgrade RUN echo yes | apt-get -y install mysql-client #RUN service mysql start # Copy the local packages files to the container workspace RUN mkdir -p /go/src/github.com/<project_root_dir>/<project_name> ENV APP_PATH github.com/<project_root_dir>/<project_name> # copy the local project into the container workspace ADD . /go/src/$APP_PATH # Get all dependencies (you can include more) RUN go get -v github.com/go-sql-driver/mysql \ github.com/gorilla/mux \ github.com/tools/godep #Install and create the build WORKDIR /go/src/$APP_PATH RUN godep go build . RUN godep go install . # Run the app command by default when the container starts ENTRYPOINT <project_name> # EXPOSE Web FrontEnd EXPOSE 8080
I have used godep as build lib but you can use anything whatever you like or don’t use anything, you can use this step if you don’t use any build lib:
RUN go build . and Run go install
- Second Step: Build the Docker Image : Simple Command
docker build -t <my-docker-app> Dockerfile
- Third Step: Run the image:
docker run -p 49160:8080 -i <my-docker-app>
Now visit to http://localhost:49160 to check your running app 🙂
I would really appreciate any feedback.