Files

30 lines
917 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
# Writable dir for admin image uploads (mount a volume in compose for persistence).
# Keep this outside public/: Next standalone does not serve runtime public files.
RUN rm -rf ./public/uploads \
&& mkdir -p ./uploads \
&& chown -R nextjs:nodejs ./uploads
USER nextjs
EXPOSE 3000
CMD ["node", "server.js"]