1.6GB Docker Image, 8-Minute Builds. Add Runners?
Your image is huge and every code change rebuilds from scratch. A teammate wants to just add more CI runners. Defend how you actually fix it.
Answer key reviewed by Branko Petric
Read first: Optimizing Docker Image Size and Build Speed
Your decision
Your Node app's Docker image is 1.6GB and every code change rebuilds dependencies from scratch, so CI takes 8 minutes. A teammate says just add more CI runners. How do you fix the image, and why?
The situation
Your team's Node service ships as a Docker image. The image is 1.6GB, and CI takes about 8 minutes per run because every commit reinstalls all dependencies before building.
Context
The Dockerfile starts from a full node base image, copies the whole project in one COPY, then runs npm install and the build. There is no .dockerignore. A teammate suggests just adding more CI runners so builds finish faster.
Related challenges
- The Build Is Slow, So Let's Just Add --no-cache to CI?
CI Docker builds crept to 11 minutes and once shipped a stale dependency. A teammate wants --no-cache on every build. Defend what you actually do first.
- The Container Needs Docker, So Mount the Socket and Run --privileged?
A CI job needs to build images and a teammate wants to bind-mount the Docker socket and run --privileged to fix permission errors. Defend the safe approach.
- Tests Pass Locally, Fail in CI. Just Retry?
Your suite is green on your laptop but red in CI. A teammate wants to add a retry and re-run until green. Defend what you actually do.
- The Pipeline Is Slow. Skip Tests to Ship?
A 40-minute pipeline is blocking releases. A teammate wants to skip the test stage to ship faster. Defend your call.