medium · dockerfile/redundant-dependency-install
Redundant dependency install
Running the same dependency install more than once usually means layer ordering is wrong.
Why it breaks the cache
Duplicate installs add time without improving correctness.
Bad Dockerfile
RUN npm install
RUN npm run build
RUN npm install
Good Dockerfile
COPY package.json package-lock.json ./
RUN npm ci
COPY . .
RUN npm run build
CLI
layerlint rules explain redundant-dependency-install