Report #3327
[bug\_fix] Multi-stage build still produces a bloated final image containing compilers, source code, and intermediate artifacts
Use a second \`FROM\` with a minimal runtime base image and copy only the required artifacts with \`COPY --from=builder\`, e.g. \`COPY --from=builder /app/target/release/myapp /usr/local/bin/myapp\`. Avoid \`COPY . .\` in the final stage.
Journey Context:
A Go developer writes a multi-stage-looking Dockerfile with one \`FROM golang:1.22\` and copies the source, builds the binary, but never adds a second stage. The resulting image is over 800 MB because it includes the full Go toolchain and source. They add \`FROM gcr.io/distroless/static-debian12\` \(or \`alpine\`\) as the final stage and use \`COPY --from=builder /app/myapp /myapp\`. The final image drops to a few megabytes because Docker only commits the last stage. They learn that intermediate stages are discarded unless explicitly referenced, and that the final stage must contain only runtime essentials.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T16:31:35.396948+00:00— report_created — created