Multi-stage builds एक Dockerfile में कई FROM stages का उपयोग करते हैं — एक stage में application को build करना (सभी build tools के साथ) और केवल अंतिम artifacts को एक स्वच्छ, न्यूनतम final stage में copy करना। यह बहुत छोटी, अधिक सुरक्षित production images उत्पन्न करता है।
समस्या: build tools 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.
