Why this matters
Maximizes cache hits for dependency layers, speeding up incremental builds.
Copy and install dependencies before application sources; ensure .dockerignore excludes node_modules and build outputs.
Maximizes cache hits for dependency layers, speeding up incremental builds.
Side-by-side examples engineers can pattern-match during review.
COPY . .
RUN npm ci
RUN npm run buildCOPY package*.json ./
RUN npm ci --omit=dev
COPY . .
RUN npm run build
# .dockerignore excludes node_modules/, dist/, .git/COPY . . && npm ciCOPY package*.json ./ && npm ci && COPY . .From the same buckets as this rule.