3faa11fef0
CI/CD Pipeline / Dedup Check - skip PR tests when covered by push pipeline (pull_request) Successful in 0s
CI/CD Pipeline / Check push changed paths (pull_request) Has been skipped
CI/CD Pipeline / Build Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 2s
CI/CD Pipeline / Build Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Frontend Lint (pull_request) Has been skipped
CI/CD Pipeline / Frontend Unit Tests (pull_request) Has been skipped
CI/CD Pipeline / PR Build Web Image (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been skipped
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been skipped
CI/CD Pipeline / Staging API Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / ACR Image Cleanup (pull_request) Has been skipped
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 38s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 3m5s
CI/CD Pipeline / Unit Tests (pull_request) Failing after 3m9s
CI/CD Pipeline / PR Build Worker Image (pull_request) Failing after 3m22s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 3m47s
CI/CD Pipeline / Integration Tests (pull_request) Successful in 4m3s
CI/CD Pipeline / Validate - Python (mypy + alembic) (pull_request) Successful in 4m24s
CI/CD Pipeline / Validate - Style (pull_request) Successful in 4m36s
CI/CD Pipeline / Build Production API Image (pull_request) Has been cancelled
CI/CD Pipeline / Build Production Web Image (pull_request) Has been cancelled
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been cancelled
CI/CD Pipeline / Deploy Production (pull_request) Has been cancelled
CI/CD Pipeline / Production Browser E2E (pull_request) Has been cancelled
CI/CD Pipeline / Canary Release to Production (pull_request) Has been cancelled
CI/CD Pipeline / CI Gate (pull_request) Has been cancelled
CI/CD Pipeline / Validate - Security (pull_request) Has been cancelled
AI Code Review / AI Code Review (pull_request) Has been cancelled
PR Automation / Auto Merge on CI Green + Approved (pull_request) Has been cancelled
1. 黑屏检测(blackdetect):抽帧前先用 ffmpeg blackdetect(d=0.3,pic_th=0.98,pix_th=0.10) 扫描成片黑屏区间,
seek 点落在黑屏内时偏移到最近非黑屏位置;整段全黑则保留中点并打 warning 日志。避免封面/首帧落到黑屏。
2. 封面批量抽帧+并发上传:5次串行 ffmpeg -ss seek 改成单次 ffmpeg select between(t,...) 一次输出 5 帧;
5帧上传 OSS 用 ThreadPoolExecutor 并发(max_workers=min(8,N))。目标封面阶段从 ~3.1s 压到 <1.5s。
单次 select 失败/命中不足自动回退到单帧 -ss seek 兜底,保证鲁棒性。
3. Worker Dockerfile 加 fonts-noto-cjk 安装与 fc-cache:
- 在 worker.Dockerfile apt-get install 显式加 fonts-noto-cjk + fontconfig(base 镜像漂移兜底)
- build 时 fc-cache -fv + fc-match 'Noto Sans CJK SC' 校验,确保 fc-match 能解析到 Noto,
不再依赖 PIL 直读 ttf 兜底路径。
64 lines
2.5 KiB
Docker
Executable File
64 lines
2.5 KiB
Docker
Executable File
# ============================================================
|
||
# Worker Dockerfile - 极简化
|
||
# 从预构建统一基础镜像开始,仅叠加业务代码
|
||
# 基础镜像包含:系统依赖 + 全部 Python 依赖 + CJK 字体
|
||
# 构建时间目标:< 5 分钟
|
||
# ============================================================
|
||
|
||
FROM xiaoxia-registry.cn-hangzhou.cr.aliyuncs.com/xiaoxiakeji/saas-worker-base:latest
|
||
|
||
# 构建参数:版本号(CI 传入 commit hash)
|
||
ARG APP_VERSION=dev
|
||
|
||
# 使用阿里云镜像加速
|
||
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
|
||
|
||
# CJK 字体保障:确保 fonts-noto-cjk 已安装(base 镜像漂移兜底)+ 重建字体缓存
|
||
# 验证 fc-match 能正确解析 Noto Sans CJK SC,避免 PIL 直读 ttf 兜底
|
||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||
fonts-noto-cjk \
|
||
fontconfig \
|
||
&& rm -rf /var/lib/apt/lists/* \
|
||
&& fc-cache -fv \
|
||
&& fc-match 'Noto Sans CJK SC' | grep -qi 'noto' \
|
||
&& echo "[font] fc-match Noto Sans CJK SC: $(fc-match 'Noto Sans CJK SC' | head -1)"
|
||
|
||
# 创建非 root 用户
|
||
RUN groupadd -r celery \
|
||
&& useradd -r -g celery -d /app -s /sbin/nologin celery \
|
||
&& mkdir -p /app/generated \
|
||
&& chown celery:celery /app/generated
|
||
|
||
WORKDIR /app
|
||
|
||
# 设置 Python 环境变量
|
||
ENV PATH="/opt/venv/bin:$PATH"
|
||
ENV PYTHONPATH=/app:/app/apps/api:/app/packages
|
||
ENV PYTHONUNBUFFERED=1
|
||
ENV APP_VERSION=$APP_VERSION
|
||
|
||
# 复制文件(按变化频率从低到高排序,最大化层缓存命中)
|
||
COPY alembic.ini /app/alembic.ini
|
||
COPY migrations/ /app/migrations/
|
||
COPY packages/ /app/packages/
|
||
# PR #1844 起,worker 还需要加载 apps.api.app.tasks.lipsync_tts,
|
||
# 该 task 依赖 app.services.* 与 app.core.celery_app(PYTHONPATH=/app/apps/api 下解析)。
|
||
# 为避免后续新增 task 再次漏 COPY,直接把整个 apps/api/app/ 复制进 worker 镜像。
|
||
COPY apps/api/app/ /app/apps/api/app/
|
||
|
||
# Worker 启动脚本
|
||
COPY infra/docker/entrypoint-worker.sh /usr/local/bin/entrypoint-worker.sh
|
||
RUN chmod +x /usr/local/bin/entrypoint-worker.sh
|
||
|
||
# 业务代码(变化最频繁,放最后)
|
||
COPY apps/worker/ /app/apps/worker/
|
||
|
||
# 健康检查:扫描所有进程的 cmdline 查找 celery 进程
|
||
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
|
||
CMD grep -lq celery /proc/[0-9]*/cmdline 2>/dev/null || exit 1
|
||
|
||
USER celery
|
||
WORKDIR /app/apps/worker
|
||
CMD ["/usr/local/bin/entrypoint-worker.sh"]
|