Files
NianAIGC/Dockerfile
2026-08-15 22:11:08 +08:00

48 lines
1.3 KiB
Docker

FROM node:22-alpine AS deps
WORKDIR /app
ENV NEXT_TELEMETRY_DISABLED=1
# Use a free mainland-China npm mirror by default. CI can override this with
# --build-arg NPM_REGISTRY=https://registry.npmjs.org if its egress allows it.
ARG NPM_REGISTRY=https://registry.npmmirror.com
COPY package.json package-lock.json ./
RUN npm ci \
--registry="${NPM_REGISTRY}" \
--fetch-retries=5 \
--fetch-timeout=120000 \
--fetch-retry-mintimeout=10000 \
--fetch-retry-maxtimeout=60000 \
--no-audit \
--no-fund
FROM node:22-alpine AS builder
WORKDIR /app
ENV NEXT_TELEMETRY_DISABLED=1
COPY --from=deps /app/node_modules ./node_modules
COPY . .
RUN npm run build && npm prune --omit=dev
FROM node:22-alpine AS runner
WORKDIR /app
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
ENV PORT=3000
ENV ZHINIAN_RUNTIME_DIR=/app/.runtime
COPY --from=builder /app/package.json /app/package-lock.json ./
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/.next ./.next
COPY --from=builder /app/public ./public
COPY --from=builder /app/scripts ./scripts
COPY --from=builder /app/database ./database
COPY --from=builder /app/next.config.ts ./next.config.ts
RUN mkdir -p /app/.runtime/data /app/.runtime/uploads /app/.runtime/generated-results
EXPOSE 3000
CMD ["sh", "-c", "npx next start --hostname 0.0.0.0 --port ${PORT:-3000}"]