3bea00aa56
CI/CD Pipeline / Check if frontend-only change (push) Has been skipped
CI/CD Pipeline / PR Build Web Image (push) Has been skipped
CI/CD Pipeline / PR Build API Image (push) Has been skipped
CI/CD Pipeline / PR Build Worker Image (push) Has been skipped
CI/CD Pipeline / Frontend Lint (push) Successful in 41s
CI/CD Pipeline / Frontend Unit Tests (push) Failing after 1m15s
CI/CD Pipeline / Validate - Migration (alembic) (push) Successful in 1m49s
CI/CD Pipeline / Validate - Type Check (mypy) (push) Successful in 1m56s
CI/CD Pipeline / Build Production Web Image (push) Successful in 2m7s
CI/CD Pipeline / Build Production API Image (push) Successful in 2m10s
CI/CD Pipeline / Build Staging Web Image (push) Successful in 2m20s
CI/CD Pipeline / Build Staging API Image (push) Successful in 2m21s
CI/CD Pipeline / Build Production Worker Image (push) Successful in 2m51s
CI/CD Pipeline / Deploy Production (push) Has been skipped
CI/CD Pipeline / Build Staging Worker Image (push) Successful in 2m53s
CI/CD Pipeline / Production Browser E2E (push) Has been skipped
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (push) Failing after 51s
CI/CD Pipeline / Staging E2E Tests (push) Has been skipped
CI/CD Pipeline / Staging API Integration Tests (push) Has been skipped
CI/CD Pipeline / ACR Image Cleanup (push) Has been skipped
CI/CD Pipeline / Canary Release to Production (push) Has been skipped
CI/CD Pipeline / Validate - Code Quality (push) Successful in 4m56s
CI/CD Pipeline / Unit Tests (push) Successful in 5m0s
CI/CD Pipeline / Integration Tests (push) Successful in 1m57s
CI/CD Pipeline / CI Gate (push) Has been skipped
- Bug6(P1): 所有Dockerfile基础镜像从daocloud切到私有ACR (xiaoxia-registry.cn-hangzhou.cr.aliyuncs.com/xiaoxiakeji/base/) - 新增scripts/ci/sync_base_images.sh - 基础镜像同步脚本 - 覆盖: python:3.12-slim-bookworm / python:3.12-slim / node:20 / nginx:alpine
54 lines
2.0 KiB
Docker
Executable File
54 lines
2.0 KiB
Docker
Executable File
# ============================================================
|
|
# API Dockerfile - 专门用于 FastAPI 应用
|
|
# 优化:依赖分层缓存 + 多阶段构建基础层
|
|
# ============================================================
|
|
|
|
# 基础镜像:Python 3.12
|
|
FROM xiaoxia-registry.cn-hangzhou.cr.aliyuncs.com/xiaoxiakeji/base/python:3.12-slim-bookworm
|
|
|
|
# 使用阿里云镜像加速
|
|
RUN sed -i 's|deb.debian.org|mirrors.aliyun.com|g' /etc/apt/sources.list.d/debian.sources 2>/dev/null || \
|
|
sed -i 's|deb.debian.org|mirrors.aliyun.com|g' /etc/apt/sources.list 2>/dev/null || true
|
|
|
|
# 安装系统依赖
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
libpq-dev \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# 设置工作目录
|
|
WORKDIR /app
|
|
|
|
# ---- 依赖分层:基础依赖(变化少,缓存命中率高)----
|
|
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 /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
|
|
|
|
# 复制应用代码
|
|
COPY apps/api/ /app/apps/api/
|
|
COPY packages/ /app/packages/
|
|
COPY alembic.ini /app/alembic.ini
|
|
COPY migrations/ /app/migrations/
|
|
COPY alembic/ /app/alembic/
|
|
COPY scripts/ /app/scripts/
|
|
|
|
# 设置环境变量
|
|
ENV PATH="/opt/venv/bin:$PATH"
|
|
ENV PYTHONPATH=/app
|
|
ENV PYTHONUNBUFFERED=1
|
|
|
|
# 健康检查
|
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
|
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/health', timeout=5)"
|
|
|
|
# API 入口点
|
|
WORKDIR /app/apps/api
|
|
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
|