Shipping your build tools to production is the default, and it is wrong. How multi-stage builds cut a Go API image by 99%, and the Compose setup behind a reproducible dev environment.
Why Docker Changes Everything
'Works on my machine' dies with Docker. Your development environment IS your production environment, and all of it is defined in docker-compose.yml, reproducible with one command.
Multi-Stage Builds
Don't ship your build tools. A Go API goes from 1.2GB to 15MB. A Next.js app drops to just production deps.
dockerfile
# Go API: multi-stage buildFROM golang:1.24-alpine AS builderWORKDIR /appCOPY go.mod go.sum ./RUN go mod downloadCOPY . .RUN CGO_ENABLED=0 GOOS=linux go build -o server ./cmd/api# Final image: just the binaryFROM alpine:3.19RUN apk --no-cache add ca-certificatesCOPY --from=builder /app/server /serverEXPOSE 8080CMD ["/server"]# Result: ~15MB image vs 1.2GB with build tools
Docker Compose for Full Stack
Define your entire stack in one file. Use healthchecks, volumes for hot reload, and separate compose files for dev and prod.