Commit 46107c0b by imwangxiaozhou

build(backend docker): 优化生产Docker构建,集成运维面板自动构建

修改 .dockerignore 配置,添加注释明确仅排除根目录的构建产物;重构生产Dockerfile为多阶段构建,自动打包运维面板前端资源,不再依赖本地预构建文件。
1 parent d6764f73
......@@ -3,8 +3,9 @@ __pycache__/
*.pyc
*.pyo
*.egg-info/
dist/
build/
# 仅排除根目录 Python 构建产物 dist,保留 operation-panel/dist(运维面板静态产物)
/dist/
/build/
# 数据库(容器内重新生成)
dev.db
......
# ============ Stage 1: Builder ============
# ============ Stage 1: 前端构建(运维面板 operation-panel)============
FROM node:20-slim AS panel-builder
WORKDIR /panel
# 先拷贝依赖清单以利用构建缓存
COPY operation-panel/package.json operation-panel/package-lock.json* ./
RUN npm install --registry=https://registry.npmmirror.com
# 拷贝源码并构建
COPY operation-panel/ ./
RUN npm run build
# 产物位于 /panel/dist(.gitignore 已排除 dist,此处保证镜像内必含产物)
# ============ Stage 2: Builder ============
FROM python:3.12-slim AS builder
WORKDIR /build
......@@ -35,7 +51,8 @@ COPY config/ ./config/
COPY skills/ ./skills/
COPY soul/ ./soul/
COPY scripts/ ./scripts/
COPY operation-panel/dist/ ./operation-panel/dist/
# 从前端构建阶段拷贝运维面板产物
COPY --from=panel-builder /panel/dist/ ./operation-panel/dist/
COPY sitecustomize.py ./
# 创建日志目录并设置权限
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!