Multi-stage builds menggunakan beberapa stage FROM dalam satu Dockerfile — membangun aplikasi dalam satu stage (dengan semua build tools) dan menyalin hanya artifacts akhir ke stage akhir yang bersih dan minimal. Ini menghasilkan image production yang jauh lebih kecil dan lebih aman.
Masalah: build tools membuat image membengkak
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.
