ci: 启用BuildKit分布式缓存+Gitea Registry,优化构建速度
Deploy / Staging E2E Tests (push) Has been skipped
Deploy / Build Production Runtime Images (push) Has been skipped
Deploy / Deploy Production (push) Has been skipped
Deploy / Production Browser E2E (push) Has been skipped
Deploy / Deploy Staging (push) Failing after 138h40m13s
CI/CD Pipeline / Frontend Lint (push) Failing after 138h40m24s
CI/CD Pipeline / Validate Code Quality And Tests (push) Failing after 138h40m24s
Deploy / Staging E2E Tests (push) Has been skipped
Deploy / Build Production Runtime Images (push) Has been skipped
Deploy / Deploy Production (push) Has been skipped
Deploy / Production Browser E2E (push) Has been skipped
Deploy / Deploy Staging (push) Failing after 138h40m13s
CI/CD Pipeline / Frontend Lint (push) Failing after 138h40m24s
CI/CD Pipeline / Validate Code Quality And Tests (push) Failing after 138h40m24s
- 拆分 requirements.txt: 稳定大包放 requirements-base.txt(numpy/scipy/opencv/Pillow/sqlalchemy 等),业务依赖留 requirements.txt - 优化 Dockerfile: 分两层安装依赖,基础层缓存命中率高 - CI 改用 docker buildx build,缓存存 Gitea Container Registry - 启用 Gitea Packages/Container Registry(git.xiaoxiajianji.com) - 镜像仍推内网 Registry(172.30.18.198:5000),缓存独立存 Gitea Registry
This commit is contained in:
Regular → Executable
+10
-7
@@ -1,6 +1,6 @@
|
||||
# ============================================================
|
||||
# API Dockerfile - 专门用于 FastAPI 应用
|
||||
# 优化:仅包含 API 所需的依赖
|
||||
# 优化:依赖分层缓存 + 多阶段构建基础层
|
||||
# ============================================================
|
||||
|
||||
# 基础镜像:Python 3.12
|
||||
@@ -18,14 +18,17 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
# 设置工作目录
|
||||
WORKDIR /app
|
||||
|
||||
# 复制 requirements.txt(排除 worker 专用依赖)
|
||||
# API 需要 psycopg2/sqlalchemy 用于数据库连接
|
||||
# 注意:opencv、scipy 等是 worker 专用依赖,不在 API 中安装
|
||||
# ---- 依赖分层:基础依赖(变化少,缓存命中率高)----
|
||||
COPY requirements-base.txt /tmp/requirements-base.txt
|
||||
|
||||
RUN python -m venv /opt/venv \
|
||||
&& /opt/venv/bin/pip install --no-cache-dir -i https://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com -r /tmp/requirements-base.txt \
|
||||
&& rm /tmp/requirements-base.txt
|
||||
|
||||
# ---- 依赖分层:业务依赖(变化频繁)----
|
||||
COPY requirements.txt /tmp/requirements.txt
|
||||
|
||||
# 创建虚拟环境并安装依赖
|
||||
RUN python -m venv /opt/venv \
|
||||
&& /opt/venv/bin/pip install --no-cache-dir -i https://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com -r /tmp/requirements.txt \
|
||||
RUN /opt/venv/bin/pip install --no-cache-dir -i https://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com -r /tmp/requirements.txt \
|
||||
&& rm /tmp/requirements.txt
|
||||
|
||||
# 复制应用代码
|
||||
|
||||
Reference in New Issue
Block a user