Some checks failed
Test examples / Test Examples (20) (push) Has been cancelled
Test examples / Test Examples (22) (push) Has been cancelled
Lock Threads / action (push) Has been cancelled
Trigger Release / start (push) Has been cancelled
Stale issue handler / stale (push) Has been cancelled
Update Font Data / create-pull-request (push) Has been cancelled
build-and-deploy / deploy-target (push) Has been cancelled
build-and-deploy / build (push) Has been cancelled
build-and-deploy / stable - aarch64-unknown-linux-musl - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-unknown-linux-musl - node@16 (push) Has been cancelled
build-and-deploy / stable - aarch64-unknown-linux-gnu - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-unknown-linux-gnu - node@16 (push) Has been cancelled
build-and-deploy / stable - aarch64-pc-windows-msvc - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-pc-windows-msvc - node@16 (push) Has been cancelled
build-and-deploy / stable - aarch64-apple-darwin - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-apple-darwin - node@16 (push) Has been cancelled
build-and-deploy / build-wasm (nodejs) (push) Has been cancelled
build-and-deploy / build-wasm (web) (push) Has been cancelled
build-and-deploy / Deploy preview tarball (push) Has been cancelled
build-and-deploy / Potentially publish release (push) Has been cancelled
build-and-deploy / publish-turbopack-npm-packages (push) Has been cancelled
build-and-deploy / Deploy examples (push) Has been cancelled
build-and-deploy / thank you, build (push) Has been cancelled
build-and-deploy / Upload Turbopack Bytesize metrics to Datadog (push) Has been cancelled
Rspack Next.js development integration tests / Rspack integration tests (push) Has been cancelled
Rspack Next.js production integration tests / Rspack integration tests (push) Has been cancelled
Turbopack Next.js development integration tests / Next.js integration tests (push) Has been cancelled
Turbopack Next.js production integration tests / Next.js integration tests (push) Has been cancelled
Update Rspack test manifest / Update and upload Rspack development test manifest (push) Has been cancelled
Update Rspack test manifest / Update and upload Rspack production test manifest (push) Has been cancelled
Upload bundler test manifests to areweturboyet.com / Upload test results (push) Has been cancelled
Update React / create-pull-request (push) Has been cancelled
test-e2e-project-reset-cron / reset-test-project (push) Has been cancelled
Notify about the top 15 issues/PRs/feature requests (most reacted) in the last 90 days / run (push) Has been cancelled
76 lines
2.5 KiB
Docker
76 lines
2.5 KiB
Docker
# syntax=docker.io/docker/dockerfile:1
|
|
|
|
FROM node:20-alpine AS base
|
|
|
|
# Step 1. Rebuild the source code only when needed
|
|
FROM base AS builder
|
|
|
|
WORKDIR /app
|
|
|
|
# Install dependencies based on the preferred package manager
|
|
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* .npmrc* ./
|
|
# Omit --production flag for TypeScript devDependencies
|
|
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 .
|
|
|
|
# Environment variables must be present at build time
|
|
# https://github.com/vercel/next.js/discussions/14030
|
|
ARG ENV_VARIABLE
|
|
ENV ENV_VARIABLE=${ENV_VARIABLE}
|
|
ARG NEXT_PUBLIC_ENV_VARIABLE
|
|
ENV NEXT_PUBLIC_ENV_VARIABLE=${NEXT_PUBLIC_ENV_VARIABLE}
|
|
|
|
# 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 build time
|
|
# ENV NEXT_TELEMETRY_DISABLED 1
|
|
|
|
# Build Next.js based on the preferred package manager
|
|
RUN \
|
|
if [ -f yarn.lock ]; then yarn build; \
|
|
elif [ -f package-lock.json ]; then npm run build; \
|
|
elif [ -f pnpm-lock.yaml ]; then pnpm build; \
|
|
else npm run build; \
|
|
fi
|
|
|
|
# Note: It is not necessary to add an intermediate step that does a full copy of `node_modules` here
|
|
|
|
# Step 2. Production image, copy all the files and run next
|
|
FROM base AS runner
|
|
|
|
WORKDIR /app
|
|
|
|
# Don't run production as root
|
|
RUN addgroup --system --gid 1001 nodejs
|
|
RUN adduser --system --uid 1001 nextjs
|
|
USER nextjs
|
|
|
|
COPY --from=builder /app/public ./public
|
|
|
|
# Automatically leverage output traces to reduce image size
|
|
# https://nextjs.org/docs/advanced-features/output-file-tracing
|
|
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
|
|
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
|
|
|
|
# Environment variables must be redefined at run time
|
|
ARG ENV_VARIABLE
|
|
ENV ENV_VARIABLE=${ENV_VARIABLE}
|
|
ARG NEXT_PUBLIC_ENV_VARIABLE
|
|
ENV NEXT_PUBLIC_ENV_VARIABLE=${NEXT_PUBLIC_ENV_VARIABLE}
|
|
|
|
# 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
|
|
|
|
CMD ["node", "server.js"]
|