Files
xiaoxia-saas/infra/docker/api.Dockerfile
T
saas-backend-agent 605a3eb841
CI/CD Pipeline / Check if frontend-only change (push) Has been skipped
CI/CD Pipeline / Dedup Check - skip PR tests when covered by push pipeline (push) Successful in 1s
CI/CD Pipeline / Check push changed paths (push) Successful in 1s
CI/CD Pipeline / Frontend Lint (push) Has been skipped
CI/CD Pipeline / PR Build API Image (push) Has been skipped
CI/CD Pipeline / PR Build Web Image (push) Has been skipped
CI/CD Pipeline / PR Build Worker Image (push) Has been skipped
CI/CD Pipeline / Build Staging Web Image (push) Successful in 34s
CI/CD Pipeline / Build Staging API Image (push) Successful in 57s
CI/CD Pipeline / Build Staging Worker Image (push) Successful in 2m29s
CI/CD Pipeline / Retag skipped Staging API Image (push) Has been skipped
CI/CD Pipeline / Retag skipped Staging Web Image (push) Has been skipped
CI/CD Pipeline / Retag skipped Staging Worker Image (push) Has been skipped
CI/CD Pipeline / Validate - Python (mypy + alembic) (push) Successful in 2m59s
CI/CD Pipeline / Validate - Style (push) Successful in 3m12s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (push) Successful in 52s
CI/CD Pipeline / Integration Tests (push) Successful in 4m19s
CI/CD Pipeline / ACR Image Cleanup (push) Successful in 1m57s
CI/CD Pipeline / Frontend Unit Tests (push) Successful in 5m54s
CI/CD Pipeline / Validate - Security (push) Successful in 6m32s
CI/CD Pipeline / Staging API Integration Tests (push) Successful in 4m15s
CI/CD Pipeline / Staging E2E Tests (push) Successful in 4m24s
CI/CD Pipeline / Unit Tests (push) Successful in 10m23s
CI/CD Pipeline / Build Production API Image (push) Has been skipped
CI/CD Pipeline / Build Production Web Image (push) Has been skipped
CI/CD Pipeline / Build Production Worker Image (push) Has been skipped
CI/CD Pipeline / CI Gate (push) Has been skipped
CI/CD Pipeline / Deploy Production (push) Has been skipped
CI/CD Pipeline / Canary Release to Production (push) Has been skipped
CI/CD Pipeline / Production Browser E2E (push) Has been skipped
revert(ci): 回滚 ACR 默认域名切换(公共域名凭据无效,等待自定义域名恢复)
公共域名 registry.cn-hangzhou.aliyuncs.com 使用独立凭据,
现有 ACR_USERNAME/ACR_PASSWORD 绑定自定义域名企业版实例,
docker login 报 unauthorized 无法拉/推镜像。

等 ACR 自定义域名 xiaoxia-registry 公网接入恢复后,
基于原有配置即可正常构建。
2026-09-17 07:45:05 +08:00

45 lines
2.0 KiB
Docker
Executable File
Raw 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/
# 抖音 cookies 文件:镜像内 baked-in 兜底 + host 挂载可覆盖
# - /app/configs/douyin_cookies_default.txt: 镜像构建时 COPY 的兜底 cookies(始终有效)
# - /app/configs/douyin_cookies.txt: host volume 挂载点(部署脚本 scp 覆盖,过期需更新)
RUN mkdir -p /app/configs
COPY deploy/configs/douyin_cookies.txt /app/configs/douyin_cookies_default.txt
# 初始 COPY 一份到挂载点,host 挂载为空文件时 Python 代码会自动 fallback 到 default
COPY deploy/configs/douyin_cookies.txt /app/configs/douyin_cookies.txt
# 强制升级 yt-dlp 到最新(抖音反爬经常变更,旧版 cookies 支持失效;#1968/#1963)
RUN pip install --no-cache-dir -i https://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com --upgrade "yt-dlp>=2026.8.19"
# 设置环境变量
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"]