Golang and Docker for development and production
Published in
3 min readFeb 12, 2017
Why you would want to use Docker for dev and production:
- Quick on-boarding (anyone with Docker installed can start coding without setting up any other dependencies or GOPATH variables);
- Dev environment is the same as production.
What you will learn in this article:
- How to write a single Dockerfile that allows you to build a dev container that will reload code changes you make locally (without rebuilding the container) and a production container that serves the binary build;
- This is done using shared volumes, pilu/fresh, and build arguments.
How to do it:
To get started run the following commands in Terminal:
$ mkdir myGoDockerApp
$ cd myGoDockerApp
$ mkdir app
$ cd app
$ touch app.go
Then add the following code to the app.go file: