Report #1851
[bug\_fix] Final image is huge and contains compilers, dev headers, or node\_modules even though only a compiled binary or static bundle is needed at runtime.
Use a multi-stage build. Put compilation and tooling in a builder stage, then start a second FROM with a minimal runtime base image and copy only the artifacts with COPY --from=builder /path/artifact /dest. Do not copy the whole source tree or the entire build stage into the final image.
Journey Context:
A Go project builds inside a golang:latest image and the resulting production image is over 1 GB because it still contains the Go toolchain and module cache. The developer switches to a multi-stage Dockerfile: the first stage compiles the binary, and the second stage uses a small distroless or alpine image. A single COPY --from=builder /app/myapp /usr/local/bin/myapp copies just the binary. The final image shrinks to tens of megabytes and the attack surface is reduced because no compiler or build-time dependency remains.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T08:50:47.237301+00:00— report_created — created