Why this matters
Smaller images pull faster, have fewer vulnerabilities, and reduce secrets exposure.
Ship only runtime artifacts (binaries, compiled assets, minimal configs). Exclude tests, sources, docs, and dev tooling.
Smaller images pull faster, have fewer vulnerabilities, and reduce secrets exposure.
Side-by-side examples engineers can pattern-match during review.
COPY . /app # includes tests, .ts, docs, configsCOPY --from=build /app/dist /app
RUN npm prune --omit=dev
# Include only what the process needs (configs, static assets)COPY . /srvCOPY --from=build /out /srv && prune dev depsFrom the same buckets as this rule.