Skip to content

Commit 7dc48bc

Browse files
committed
fix(build): isolate parallel npm cache mounts and bump node to 22
- Give the deps and prod-deps stages distinct BuildKit cache IDs with sharing=locked so concurrent npm ci runs no longer race on /root/.npm and fail with ENOTEMPTY. - Drop the post-install 'npm cache clean --force' in prod-deps; it was wiping the cache mount it had just filled. - Update base images from node:21 to node:22 (LTS) to silence EBADENGINE warnings from packages requiring node >= 22.
1 parent 06a098f commit 7dc48bc

1 file changed

Lines changed: 7 additions & 8 deletions

File tree

Dockerfile

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# syntax=docker/dockerfile:1.7
22

33
# Stage 1: install all deps (with cache mount so npm cache survives across builds)
4-
FROM node:21-slim AS deps
4+
FROM node:22-slim AS deps
55
WORKDIR /app
66
COPY package.json package-lock.json ./
7-
RUN --mount=type=cache,target=/root/.npm \
7+
RUN --mount=type=cache,id=npm-all,target=/root/.npm,sharing=locked \
88
npm ci --prefer-offline --no-audit --fund=false
99

1010
# Stage 2: build TypeScript + gulp assets. Source changes only invalidate from here.
11-
FROM node:21-slim AS build
11+
FROM node:22-slim AS build
1212
WORKDIR /app
1313
COPY --from=deps /app/node_modules ./node_modules
1414
COPY package.json package-lock.json tsconfig.json gulpfile.js ./
@@ -17,15 +17,14 @@ COPY src ./src
1717
RUN npm run build
1818

1919
# Stage 3: prod-only deps. Independent of source so it caches well.
20-
FROM node:21-slim AS prod-deps
20+
FROM node:22-slim AS prod-deps
2121
WORKDIR /app
2222
COPY package.json package-lock.json ./
23-
RUN --mount=type=cache,target=/root/.npm \
24-
npm ci --omit=dev --prefer-offline --no-audit --fund=false && \
25-
npm cache clean --force
23+
RUN --mount=type=cache,id=npm-prod,target=/root/.npm,sharing=locked \
24+
npm ci --omit=dev --prefer-offline --no-audit --fund=false
2625

2726
# Stage 4: minimal runtime
28-
FROM node:21-alpine AS runtime
27+
FROM node:22-alpine AS runtime
2928
ENV NODE_ENV=production
3029
ENV PORT=5000
3130
EXPOSE 5000

0 commit comments

Comments
 (0)