mirror of
https://github.com/vercel/next.js.git
synced 2026-09-20 02:25:18 +08:00
c776c25b59
This PR updates all example Dockerfiles that were using `node:18-alpine` to `node:20-alpine` to align with current LTS and address known issues in Node 18 images. - examples/with-docker/Dockerfile - examples/with-docker-compose/next-app/prod.Dockerfile - examples/with-docker-compose/next-app/dev.Dockerfile - examples/with-docker-multi-env/docker/development/Dockerfile - examples/with-docker-multi-env/docker/production/Dockerfile - examples/with-docker-multi-env/docker/staging/Dockerfile I verified local builds for each example. No behavior changes; docs/examples only. https://github.com/vercel/next.js/issues/78465 --------- Co-authored-by: Joseph <joseph.chamochumbi@vercel.com>
35 lines
1.2 KiB
Docker
35 lines
1.2 KiB
Docker
# syntax=docker.io/docker/dockerfile:1
|
|
|
|
FROM node:20-alpine
|
|
|
|
WORKDIR /app
|
|
|
|
# Install dependencies based on the preferred package manager
|
|
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* .npmrc* ./
|
|
RUN \
|
|
if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
|
|
elif [ -f package-lock.json ]; then npm ci; \
|
|
elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm i; \
|
|
# Allow install without lockfile, so example works even without Node.js installed locally
|
|
else echo "Warning: Lockfile not found. It is recommended to commit lockfiles to version control." && yarn install; \
|
|
fi
|
|
|
|
COPY src ./src
|
|
COPY public ./public
|
|
COPY next.config.js .
|
|
COPY tsconfig.json .
|
|
|
|
# Next.js collects completely anonymous telemetry data about general usage. Learn more here: https://nextjs.org/telemetry
|
|
# Uncomment the following line to disable telemetry at run time
|
|
# ENV NEXT_TELEMETRY_DISABLED 1
|
|
|
|
# Note: Don't expose ports here, Compose will handle that for us
|
|
|
|
# Start Next.js in development mode based on the preferred package manager
|
|
CMD \
|
|
if [ -f yarn.lock ]; then yarn dev; \
|
|
elif [ -f package-lock.json ]; then npm run dev; \
|
|
elif [ -f pnpm-lock.yaml ]; then pnpm dev; \
|
|
else npm run dev; \
|
|
fi
|