1
- FROM node:18 -alpine AS base
1
+ FROM node:20 -alpine AS base
2
2
3
3
# Install dependencies only when needed
4
4
FROM base AS deps
5
5
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
6
6
RUN apk add --no-cache libc6-compat
7
7
WORKDIR /app
8
8
9
- # Install dependencies based on the preferred package manager
10
- COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./
11
- RUN \
12
- if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
13
- elif [ -f package-lock.json ]; then npm ci; \
14
- elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm i --frozen-lockfile; \
15
- else echo "Lockfile not found." && exit 1; \
16
- fi
9
+ # Install package manager
10
+ RUN --mount=type=cache,id= pnpm-auth-store,target=/root/.pnpm-store \
11
+ npm i --global --no-update-notifier --no-fund pnpm@latest
12
+
13
+
14
+ # Install dependencies
15
+ COPY package.json ./
16
+ RUN pnpm i
17
17
18
18
19
19
# Rebuild the source code only when needed
@@ -27,12 +27,7 @@ COPY . .
27
27
# Uncomment the following line in case you want to disable telemetry during the build.
28
28
# ENV NEXT_TELEMETRY_DISABLED 1
29
29
30
- RUN \
31
- if [ -f yarn.lock ]; then yarn run build; \
32
- elif [ -f package-lock.json ]; then npm run build; \
33
- elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm run build; \
34
- else echo "Lockfile not found." && exit 1; \
35
- fi
30
+ RUN pnpm run build
36
31
37
32
# Production image, copy all the files and run next
38
33
FROM base AS runner
0 commit comments