medium · dockerfile/multiple-broad-copies

Multiple broad COPY instructions

Copying the full tree more than once wastes layers and hurts caching.

Why it breaks the cache

Repeated broad COPY instructions invalidate cache more often than necessary.

Bad Dockerfile

COPY . .
RUN npm run build
COPY . .

Good Dockerfile

COPY package.json package-lock.json ./
RUN npm ci
COPY . .

CLI

layerlint rules explain multiple-broad-copies

All docs · Download