Interview Prep/Docker/Dockerfile Instructions & Builds

How do you exclude dev dependencies from the final image?

BeginnerConceptDockerfile Instructions & Builds
Answer

Use a multi-stage build: install everything and compile in a builder stage, then in the runtime stage install production deps only (npm ci --omit=dev, pip install --no-cache-dir, mvn package and copy the jar) or copy only the built output.

All Docker questions Roadmap: Docker & containers

More on Dockerfile Instructions & Builds