Multi-stage builds separate build-time SDKs/compilers from runtime environments, yielding production images containing only the compiled binary and zero build tools.
dockerfile # Build stage FROM golang:1.22-alpine AS builder WORKDIR /app COPY . . RUN CGO_ENABLED=0 go build -o /server . # Production runtime stage FROM gcr.io/distroless/static-debian12 COPY --from=builder /server /server USER nonroot:nonroot ENTRYPOINT ["/server"]