You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.3 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

FROM node:20-bookworm AS deps
WORKDIR /app
RUN npm install -g pnpm@9.15.0
COPY package.json pnpm-lock.yaml* ./
COPY prisma ./prisma
RUN pnpm install --frozen-lockfile || pnpm install
FROM node:20-bookworm AS builder
WORKDIR /app
RUN npm install -g pnpm@9.15.0
COPY --from=deps /app/node_modules ./node_modules
COPY . .
# next build 预渲染会读取 env;构建期占位,运行时由 .env 覆盖
ENV DATABASE_URL=mysql://build:build@127.0.0.1:3306/build
ENV SESSION_SECRET=build-time-placeholder-secret-at-least-32-chars
ENV APP_ADMIN_PASS=build-admin-pass-not-used-at-runtime
ENV APP_OPS_PASS=build-ops-pass-not-used-at-runtime
RUN pnpm db:generate && pnpm build
FROM node:20-bookworm AS runner
WORKDIR /app
ENV NODE_ENV=production
RUN npm install -g pnpm@9.15.0
COPY --from=builder /app/package.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/prisma ./prisma
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/src ./src
COPY --from=builder /app/scripts ./scripts
COPY --from=builder /app/tsconfig.json ./tsconfig.json
COPY --from=builder /app/tsconfig.worker.json ./tsconfig.worker.json
RUN mkdir -p /app/data \
&& sed -i 's/\r$//' /app/scripts/*.sh \
&& chmod +x /app/scripts/docker-entrypoint-web.sh
EXPOSE 3100
CMD ["pnpm", "start"]