Files
note-book/backend/Dockerfile

37 lines
826 B
Docker
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Stage 1: 依赖安装 + 构建
FROM node:24-alpine
WORKDIR /app
# 允许所有包的 postinstall 脚本Prisma/esbuild 需要)
ENV NPM_CONFIG_IGNORE_SCRIPTS=false
# 复制依赖和安装脚本
COPY package.json pnpm-lock.yaml install.sh ./
RUN chmod +x install.sh && ./install.sh
# 复制 Prisma schema 并生成客户端
COPY prisma/ ./prisma/
RUN npx prisma generate
# 复制源码并构建
COPY . .
RUN npm run build
# Stage 2: 最小运行时镜像
FROM node:20-alpine AS runner
WORKDIR /app
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
# 复制 standalone 输出和静态资源
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static
COPY --from=builder /app/public ./public
COPY --from=builder /app/prisma ./prisma
EXPOSE 3000
CMD ["node", "server.js"]