Docker Tutorial #7: Multi-stage Docker Builds for Production
A common mistake is shipping your entire build environment — compilers, package managers, SDKs — in your production Docker image. A Go application needs the Go compiler to build. But once it is built, the binary runs without Go installed at all. Why include 1 GB of Go tooling in an image that only needs a 10 MB binary? Multi-stage builds solve this. They let you compile your app in one container and copy only the final artifact into a minimal production image. ...