Multi-stage builds იყენებს რამდენიმე FROM stages-ს ერთ Dockerfile-ში — აპლიკაციის აგება ხდება ერთ stage-ში (ყველა build tools-ის შესაბამისად) და მხოლოდ საბოლოო artifacts-ები კოპირდება სუფთა, მინიმალური საბოლოო stage-ში. ეს აწარმოებს ბევრად უფრო მცირე, უფრო დაცულ 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.
