24 lines
656 B
Docker
24 lines
656 B
Docker
# Runtime image for a fully assembled Next.js standalone tree.
|
|
# Build context = prebuilt/ and must already contain:
|
|
# server.js, .next/BUILD_ID, .next/static/, public/, node_modules/, …
|
|
|
|
FROM node:22-alpine
|
|
WORKDIR /app
|
|
ENV NODE_ENV=production
|
|
ENV NEXT_TELEMETRY_DISABLED=1
|
|
ENV PORT=3000
|
|
ENV HOSTNAME=0.0.0.0
|
|
|
|
RUN addgroup --system --gid 1001 nodejs \
|
|
&& adduser --system --uid 1001 nextjs
|
|
|
|
# Single COPY of an already-complete app root (avoids missing hidden .next)
|
|
COPY --chown=nextjs:nodejs . ./
|
|
|
|
# Next warns/breaks if a legacy root-level ./static exists alongside ./public
|
|
RUN rm -rf ./static
|
|
|
|
USER nextjs
|
|
EXPOSE 3000
|
|
CMD ["node", "server.js"]
|