Multi-stage builds use multiple FROM stages in one Dockerfile — building the application in one stage (with all the build tools) and copying only the final artifacts into a clean, minimal final stage. This produces much smaller, more secure production images.
The problem: build tools bloat the image
Building an app needs build tools (compilers, dev dependencies, SDKs), but the
FINAL image shouldn't include them:
→ they bloat the image (larger size, slower deploys)
→ they increase the attack surface (more software = more vulnerabilities)
→ You want only the built artifact + its runtime in the final image.
