Multi-stage builds χρησιμοποιούν πολλαπλά FROM stages σε ένα Dockerfile — δημιουργώντας την εφαρμογή σε ένα stage (με όλα τα build tools) και αντιγράφοντας μόνο τα τελικά artifacts σε ένα καθαρό, ελάχιστο τελικό stage. Αυτό παράγει πολύ μικρότερες, πιο ασφαλείς εικόνες παραγωγής.
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.
