Image size ≠ image performance.
Hidden cause
Layer invalidation.
Most Dockerfiles are written like this:
COPY . . RUN npm install
Every small file change invalidates the cache.
Correct approach
COPY package.json package-lock.json ./ RUN npm install COPY . .
Cause → Effect
-
Stable dependency layers
-
Faster rebuilds
-
Lower CI/CD costs
This is why two “same-size” images can build 5x faster than each other.
