A template for deploying a minimize golang binary docker image, which size only about 10 MB.
This example uses Travis CI and Heroku to make a demo.
Use multi-stage builds, the example Dockerfile
Make two docker file
- DockerSrc for building binary
- DockerBin for execution
See the example in old folder
Image | Size |
---|---|
source code image | 282 MB |
binary image | 10.5 MB |
Function time.LoadLocation() will panic in binary image, because of
LoadLocation looks in the directory or uncompressed zip file named by the ZONEINFO environment variable, if any, then looks in known installation locations on Unix systems, and finally looks in $GOROOT/lib/time/zoneinfo.zip.
You have to set $GOROOT and copy zoneinfo.zip manually.