35c00ccbb7
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 / 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 / Check push changed paths (push) Successful in 2s
CI/CD Pipeline / Frontend Lint (push) Has been skipped
CI/CD Pipeline / Build Staging Web Image (push) Has been skipped
CI/CD Pipeline / Build Staging Worker Image (push) Successful in 30s
CI/CD Pipeline / Frontend Unit Tests (push) Successful in 2m10s
CI/CD Pipeline / Build Staging API Image (push) Successful in 4m1s
CI/CD Pipeline / Retag skipped Staging API Image (push) Has been skipped
CI/CD Pipeline / Retag skipped Staging Worker Image (push) Has been skipped
CI/CD Pipeline / Retag skipped Staging Web Image (push) Successful in 9s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (push) Successful in 1m33s
CI/CD Pipeline / Integration Tests (push) Successful in 7m9s
CI/CD Pipeline / ACR Image Cleanup (push) Successful in 1m31s
CI/CD Pipeline / Staging API Integration Tests (push) Successful in 2m45s
CI/CD Pipeline / Staging E2E Tests (push) Successful in 2m53s
CI/CD Pipeline / Validate - Python (mypy + alembic) (push) Has been cancelled
CI/CD Pipeline / Unit Tests (push) Has been cancelled
CI/CD Pipeline / Build Production API Image (push) Has been cancelled
CI/CD Pipeline / Build Production Web Image (push) Has been cancelled
CI/CD Pipeline / Build Production Worker Image (push) Has been cancelled
CI/CD Pipeline / Deploy Production (push) Has been cancelled
CI/CD Pipeline / Production Browser E2E (push) Has been cancelled
CI/CD Pipeline / Canary Release to Production (push) Has been cancelled
CI/CD Pipeline / CI Gate (push) Has been cancelled
CI/CD Pipeline / Validate - Security (push) Has been cancelled
CI/CD Pipeline / Validate - Style (push) Has been cancelled
- api.Dockerfile: COPY deploy/configs/douyin_cookies.txt 到 /app/configs/ (ci_staging_deploy.sh 的 volume mount 会覆盖为 host 上的真实文件) - deploy/configs/douyin_cookies.txt: 替换占位符为从浏览器导出的真实匿名 cookies (31条,包含 ttwid/passport_csrf_token/odin_tt/s_v_web_id 等) - 过期后可用 scripts/refresh_douyin_cookies.py 重新导出; 过期时 extract-from-douyin 已返回 503 友好文案,不会 500
38 lines
1.4 KiB
Docker
Executable File
38 lines
1.4 KiB
Docker
Executable File
# ============================================================
|
||
# 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 文件(匿名访客 cookies,用于 yt-dlp 解析抖音视频,过期需重新导出)
|
||
RUN mkdir -p /app/configs
|
||
COPY deploy/configs/douyin_cookies.txt /app/configs/douyin_cookies.txt
|
||
|
||
# 设置环境变量
|
||
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"]
|