Skip to content

Commit 27960f8

Browse files
committed
devops: Upgrade to Node 22 and latest pnpm
To fix build problems with Node 20 and the latest pnpm 10, ref. pnpm/pnpm#9029
1 parent 63f8978 commit 27960f8

File tree

3 files changed

+689
-14
lines changed

3 files changed

+689
-14
lines changed

app/.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v20.10.0
1+
v22.14.0

app/Dockerfile

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
1-
FROM node:20-alpine AS base
1+
FROM node:22-alpine AS base
22
COPY .nvmrc ./
3-
RUN if [ "$(head -n 1 .nvmrc | cut -d'.' -f1)" != "v20" ]; then \
4-
echo "Node.js version in .nvmrc is not v20. Please update the FROM image or .nvmrc to match."; \
5-
exit 1; \
6-
fi
3+
RUN if [ "$(head -n 1 .nvmrc | cut -d'.' -f1)" != "v22" ]; then \
4+
echo "Node.js version in .nvmrc is not v22. Please update the FROM image or .nvmrc to match."; \
5+
exit 1; \
6+
fi
77

88
FROM base AS install
9+
# Enables corepack
910
RUN corepack enable
10-
RUN corepack prepare pnpm@latest --activate
11+
RUN corepack prepare pnpm@latest-10
12+
# Check if pnpm major version in package.json matches the one we're using
13+
COPY package.json ./
14+
RUN PNPM_VERSION_IN_PACKAGE=$(grep -o '"packageManager": "pnpm@[0-9]*' package.json | grep -o '[0-9]*') && \
15+
if [ "$PNPM_VERSION_IN_PACKAGE" != "10" ]; then \
16+
echo "pnpm version in package.json is not 10.x. Please update the Dockerfile or package.json to match."; \
17+
exit 1; \
18+
fi
1119
WORKDIR /app
1220
COPY pnpm-lock.yaml ./
1321
RUN --mount=type=cache,id=pnpm,target=/root/.local/share/pnpm/store pnpm fetch --frozen-lockfile
@@ -35,9 +43,9 @@ FROM install AS test
3543
COPY --from=install /app /app
3644
WORKDIR /app
3745
CMD pnpm run tsc && \
38-
pnpm run lint --quiet && \
39-
pnpm test -- --ci --silent && \
40-
pnpm run build
46+
pnpm run lint --quiet && \
47+
pnpm test -- --ci --silent && \
48+
pnpm run build
4149

4250
FROM base AS runner
4351
RUN apk add --no-cache dumb-init
@@ -63,6 +71,6 @@ COPY --from=build --chown=nextjs:nodejs /app/.next/static ./public/_next/static
6371

6472
USER nextjs
6573
EXPOSE 3000
66-
ENV PORT 3000
67-
ENV NODE_ENV production
74+
ENV PORT=3000
75+
ENV NODE_ENV=production
6876
CMD ["dumb-init","node", "server.js"]

0 commit comments

Comments
 (0)