Multi-stage builds gebruiken meerdere FROM stages in één Dockerfile — het bouwen van de toepassing in één stage (met alle bouwtools) en het kopiëren van alleen de uiteindelijke artefacten naar een schone, minimale eindstage. Dit levert veel kleinere, veiligere productieafbeeldingen op.
Het probleem: bouwtools maken de afbeelding groter
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.
