Commit 2d6e9afb by imwangxiaozhou

build(agent-admin后端): 为开发环境Dockerfile添加前端多阶段构建

新增前端多阶段构建环节,使用node:20-slim镜像编译operation-panel前端代码,将构建产物复制至Python运行时镜像,使开发容器内置前端静态资源,无需本地预构建前端。
1 parent 46107c0b
# ============ 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: Runtime ============
FROM python:3.12-slim FROM python:3.12-slim
# 设置环境变量,避免 Python 缓冲输出和生成 .pyc 文件 # 设置环境变量,避免 Python 缓冲输出和生成 .pyc 文件
...@@ -26,6 +43,8 @@ COPY config/ ./config/ ...@@ -26,6 +43,8 @@ COPY config/ ./config/
COPY skills/ ./skills/ COPY skills/ ./skills/
COPY soul/ ./soul/ COPY soul/ ./soul/
COPY scripts/ ./scripts/ COPY scripts/ ./scripts/
# 从前端构建阶段拷贝运维面板产物
COPY --from=panel-builder /panel/dist/ ./operation-panel/dist/
COPY sitecustomize.py ./ COPY sitecustomize.py ./
RUN chmod +x /app/scripts/start-dev.sh /app/scripts/start-prod.sh /app/scripts/start-scheduler.sh RUN chmod +x /app/scripts/start-dev.sh /app/scripts/start-prod.sh /app/scripts/start-scheduler.sh
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!