Initial commit: 浼佷笟寰俊 AI 鏈哄櫒浜哄姪鐞?MVP
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
52
deploy/docker/admin.Dockerfile
Normal file
52
deploy/docker/admin.Dockerfile
Normal file
@@ -0,0 +1,52 @@
|
||||
# 生产环境 Admin Dockerfile(最小构建)
|
||||
# 用途:构建优化的 Next.js 生产镜像
|
||||
FROM node:20-alpine AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# 设置 npm 镜像(可选,根据网络情况)
|
||||
ARG NPM_REGISTRY=https://registry.npmjs.org
|
||||
RUN npm config set registry ${NPM_REGISTRY}
|
||||
|
||||
# 复制依赖文件
|
||||
COPY admin/package.json admin/package-lock.json* ./
|
||||
|
||||
# 安装依赖
|
||||
RUN npm ci --legacy-peer-deps --only=production
|
||||
|
||||
# 复制源代码
|
||||
COPY admin/ .
|
||||
|
||||
# 构建 Next.js 应用
|
||||
ENV NEXT_TELEMETRY_DISABLED=1
|
||||
RUN npm run build
|
||||
|
||||
# 生产镜像
|
||||
FROM node:20-alpine
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# 从 builder 复制构建产物
|
||||
COPY --from=builder /app/.next/standalone ./
|
||||
COPY --from=builder /app/.next/static ./.next/static
|
||||
COPY --from=builder /app/public ./public
|
||||
|
||||
# 设置环境变量
|
||||
ENV NODE_ENV=production
|
||||
ENV PORT=3000
|
||||
ENV NEXT_TELEMETRY_DISABLED=1
|
||||
|
||||
# 创建非 root 用户
|
||||
RUN addgroup -g 1001 -S nodejs && \
|
||||
adduser -S nextjs -u 1001 && \
|
||||
chown -R nextjs:nodejs /app
|
||||
|
||||
USER nextjs
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
# 健康检查
|
||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
|
||||
CMD node -e "require('http').get('http://localhost:3000', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})" || exit 1
|
||||
|
||||
CMD ["node", "server.js"]
|
||||
Reference in New Issue
Block a user