Docker Build: Use Multi-Stage Builds
A single-stage Dockerfile bundles compilers, build tools, dev dependencies, and source code into the final image. Multi-stage builds split this into a builder stage that compiles your app and a minimal runtime stage that copies only the production artifact. The result: smaller images, faster pushes, tighter security surface, and significantly shorter CI build times.
How It Works
A monolithic Dockerfile ships compilers, dev tools, and source alongside your app. Multi-stage builds isolate the build environment, copying only the production artifact into a minimal runtime image.
Includes build tools, dev deps, source maps
Full dependency install + build in single layer
gcc, make, python, npm dev packages all present