Files
kt-financial-system/Dockerfile
你的用户名 c5dd72c68c
Some checks failed
Deploy to Production / Build and Test (push) Has been cancelled
Deploy to Production / Deploy to Server (push) Has been cancelled
fix: 修复Docker日志目录缺失问题
- 添加nginx和backend日志目录创建
- 确保supervisord可以正常写入日志
- 修复容器启动失败问题
2025-11-04 21:10:21 +08:00

67 lines
1.6 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 turbo.json ./
COPY apps ./apps
COPY packages ./packages
COPY internal ./internal
COPY scripts ./scripts
# 安装依赖如果存在lock文件则使用
RUN pnpm install --no-frozen-lockfile
# 构建前端
RUN pnpm build
# ===== 后端构建阶段 =====
FROM frontend-builder AS backend-builder
WORKDIR /app
# 后端依赖已经在前端构建阶段安装完成
# 构建后端(如果需要)
WORKDIR /app/apps/backend
RUN pnpm build || echo "No build script or build not needed"
# ===== 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 && \
mkdir -p /var/log/nginx && \
mkdir -p /var/log/backend
# 复制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"]