@@ -7,9 +7,11 @@ RUN apk add --no-cache libc6-compat
77WORKDIR /app
88
99# Install dependencies based on the preferred package manager
10- COPY package.json pnpm-lock.yaml* ./
10+ COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* .npmrc * ./
1111RUN \
12- if [ -f pnpm-lock.yaml ]; then yarn global add pnpm && pnpm i --frozen-lockfile; \
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; \
1315 else echo "Lockfile not found." && exit 1; \
1416 fi
1517
@@ -24,7 +26,12 @@ COPY . .
2426# Uncomment the following line in case you want to disable telemetry during the build.
2527# ENV NEXT_TELEMETRY_DISABLED 1
2628
27- RUN yarn build
29+ RUN \
30+ if [ -f yarn.lock ]; then yarn run build; \
31+ elif [ -f package-lock.json ]; then npm run build; \
32+ elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm run build; \
33+ else echo "Lockfile not found." && exit 1; \
34+ fi
2835
2936# If using npm comment out above and use below instead
3037# RUN npm run build
@@ -42,10 +49,6 @@ RUN adduser --system --uid 1001 nextjs
4249
4350COPY --from=builder /app/public ./public
4451
45- # Set the correct permission for prerender cache
46- RUN mkdir .next
47- RUN chown nextjs:nodejs .next
48-
4952# Automatically leverage output traces to reduce image size
5053# https://nextjs.org/docs/advanced-features/output-file-tracing
5154COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
0 commit comments