Multi-stage build example of a Golang app.
We use multi-stage builder to build the Go app and then use the scratch image to run the generated binary.
With this strategy you get a small image size of a few MBs.
All depenencies are managed with go dep.
This example use Gin to run a http server.
Build docker image:
docker build -t go-docker-example .
Run generated image:
docker run -it -p 8080:8080 go-docker-example
Now test it:
http://localhost:8080/ping