Files
xiaoxia-saas/infra/docker/api.Dockerfile
xiaoxia 8f1d6f20d9
CI/CD Pipeline / Validate - Migration (alembic) (push) Successful in 2m42s
CI/CD Pipeline / Validate - Type Check (mypy) (push) Successful in 2m43s
CI/CD Pipeline / Build Staging API Image (push) Successful in 2m24s
CI/CD Pipeline / Build Staging Web Image (push) Successful in 2m1s
CI/CD Pipeline / Frontend Unit Tests (push) Successful in 4m34s
CI/CD Pipeline / Validate - Code Quality (push) Successful in 9m24s
CI/CD Pipeline / Unit Tests (push) Successful in 13m11s
CI/CD Pipeline / Build Staging Worker Image (push) Successful in 13m45s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (push) Successful in 3m41s
CI/CD Pipeline / Integration Tests (push) Successful in 10m46s
CI/CD Pipeline / ACR Image Cleanup (push) Successful in 49s
CI/CD Pipeline / Staging E2E Tests (push) Failing after 59s
CI/CD Pipeline / Staging API Integration Tests (push) Successful in 3m1s
CI/CD Pipeline / CI Gate (push) Failing after 690h20m13s
CI/CD Pipeline / Canary Release to Production (push) Failing after 690h17m10s
CI/CD Pipeline / Deploy Production (push) Failing after 690h27m7s
CI/CD Pipeline / Production Browser E2E (push) Failing after 690h27m7s
CI/CD Pipeline / Build Production Worker Image (push) Failing after 690h27m9s
CI/CD Pipeline / Build Production Web Image (push) Failing after 690h27m9s
CI/CD Pipeline / PR Build Worker Image (push) Failing after 690h39m55s
CI/CD Pipeline / Build Production API Image (push) Failing after 690h27m9s
CI/CD Pipeline / PR Build Web Image (push) Failing after 690h39m57s
CI/CD Pipeline / PR Build API Image (push) Failing after 690h39m59s
CI/CD Pipeline / Check if frontend-only change (push) Failing after 690h40m25s
CI/CD Pipeline / Frontend Lint (push) Failing after 690h40m24s
fix(api): add /app/apps/api to PYTHONPATH in api.Dockerfile (#1427)
Co-authored-by: xiaoxia <dev@xiaoxiajianji.com>
Co-committed-by: xiaoxia <dev@xiaoxiajianji.com>
2026-08-18 20:46:00 +08:00

35 lines
1.2 KiB
Docker
Executable File
Raw Permalink 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.
# ============================================================
# API Dockerfile - FastAPI 应用
# 优化:从预构建基础镜像开始,仅叠加业务代码
# 基础镜像包含所有系统依赖和 Python 依赖,构建时间 < 5 分钟
# ============================================================
FROM xiaoxia-registry.cn-hangzhou.cr.aliyuncs.com/xiaoxiakeji/saas-api-base:latest
# 构建参数:版本号(CI 传入 commit hash)
ARG APP_VERSION=dev
# 设置工作目录
WORKDIR /app
# 复制应用代码(按变化频率从低到高排序,最大化层缓存命中)
COPY alembic.ini ./alembic.ini
COPY migrations/ ./migrations/
COPY alembic/ ./alembic/
COPY scripts/ ./scripts/
COPY packages/ ./packages/
COPY apps/api/ ./apps/api/
# 设置环境变量
ENV PATH="/opt/venv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
ENV PYTHONPATH=/app:/app/apps/api
ENV PYTHONUNBUFFERED=1
ENV APP_VERSION=$APP_VERSION
# 健康检查
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 入口点
CMD ["uvicorn", "apps.api.main:app", "--host", "0.0.0.0", "--port", "8000"]