Multi-stage-rakennukset käyttävät useita FROM-vaiheita yhdessä Dockerfilessa — sovellusta rakennetaan yhdessä vaiheessa (kaikilla rakennustyökaluilla) ja vain lopulliset artefaktit kopioidaan puhtaaseen, minimalistiseen loppuvaiheeseen. Tämä tuottaa paljon pienempiä ja turvallisempia tuotantokuvia.
Ongelma: rakennustyökalujen paisuminen
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.
