Files
kt-financial-system/Dockerfile
你的用户名 697bb3932c
Some checks failed
Deploy to Production / deploy (push) Has been cancelled
修复Dockerfile,支持无pnpm-lock.yaml的构建
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-04 17:25:11 +08:00

68 lines
1.5 KiB
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.

# ===== 前端构建阶段 =====
FROM node:20-alpine AS frontend-builder
WORKDIR /app
# 安装pnpm
RUN npm install -g pnpm@9
# 复制package文件
COPY package.json pnpm-workspace.yaml ./
COPY apps ./apps
COPY packages ./packages
COPY internal ./internal
# 安装依赖如果存在lock文件则使用
RUN pnpm install --no-frozen-lockfile
# 构建前端
RUN pnpm build
# ===== 后端构建阶段 =====
FROM node:20-alpine AS backend-builder
WORKDIR /app
# 复制后端代码
COPY apps/backend ./apps/backend
COPY package.json ./
# 安装pnpm和依赖
RUN npm install -g pnpm@9 && \
cd apps/backend && \
pnpm install --no-frozen-lockfile
# ===== Nginx + Node.js 运行阶段 =====
FROM node:20-alpine AS runner
WORKDIR /app
# 安装nginx和supervisord
RUN apk add --no-cache nginx supervisor
# 安装pnpm
RUN npm install -g pnpm@9
# 从构建阶段复制前端产物
COPY --from=frontend-builder /app/apps/web-antd/dist /usr/share/nginx/html
# 从构建阶段复制后端代码和依赖
COPY --from=backend-builder /app/apps/backend /app/backend
COPY --from=backend-builder /app/node_modules /app/node_modules
# 创建nginx配置
RUN mkdir -p /run/nginx && \
mkdir -p /var/log/supervisor
# 复制nginx配置
COPY docker/nginx.conf /etc/nginx/nginx.conf
# 复制supervisor配置
COPY docker/supervisord.conf /etc/supervisord.conf
# 暴露端口
EXPOSE 80 3000
# 启动supervisor管理nginx和backend
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisord.conf"]