મલ્ટી-સ્ટેજ બિલ્ડ્સ એક Dockerfile માં બહુવિધ FROM સ્ટેજેસ ઉપયોગ કરે છે — એક સ્ટેજમાં એપ્લિકેશન બિલ્ડ કરે છે (તમામ બિલ્ડ ટૂલ્સ સાથે) અને અંતિમ આર્ટિફેક્ટ્સને સ્વચ્છ, ન્યૂનતમ અંતિમ સ્ટેજમાં કૉપી કરે છે. આ ખૂબ જ નાની, વધુ સુરક્ષિત પ્રોડક્શન ઇમેજ બનાવે છે.
સમસ્યા: બિલ્ડ ટૂલ્સ ઇમેજને ફૂલાવે છે
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.
