coding · Claude Code · free
Optimize this Dockerfile. My builds are slow and my image is huge. Current Dockerfile: Stack: [LANGUAGE + RUNTIME + PACKAGE MANAGER] Final image size now: [MB] Build time on cold cache: [SECONDS] Deployment target: [K8S / FARGATE / RAILWAY / FLY] Deliver a rewritten Dockerfile plus a bulleted "why" for each change. Cover: Multi stage build — builder → runtime, only artifacts copied over Layer order — dependencies before source so npm ci / pip install caches BuildKit cache mounts for package managers platform=$BUILDPLATFORM if I need multi arch Distroless / slim / Alpine trade offs for THIS runtime (Alpine + musl is a trap for some) Non root user with explicit UID, correct WORKDIR ownership No secrets in layers, no ADD from URLs, no latest tags HEALTHCHECK that matches how the orchestrator probes A .dockerignore that would kill 80% of the context size Expected size + build time after changes
#docker #devops #optimization