97359ef77f
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 7s
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 / Frontend Lint (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 19s
CI/CD Pipeline / Build Staging Web Image (push) Successful in 16s
CI/CD Pipeline / Build Staging API Image (push) Successful in 17s
CI/CD Pipeline / Build Staging Worker Image (push) Successful in 37s
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 1m50s
CI/CD Pipeline / Integration Tests (push) Successful in 2m1s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (push) Successful in 1m10s
CI/CD Pipeline / Validate - Style (push) Successful in 2m54s
CI/CD Pipeline / ACR Image Cleanup (push) Successful in 1m45s
CI/CD Pipeline / Staging E2E Tests (push) Failing after 1m51s
CI/CD Pipeline / Staging API Integration Tests (push) Successful in 3m32s
CI/CD Pipeline / Frontend Unit Tests (push) Successful in 6m23s
CI/CD Pipeline / Unit Tests (push) Successful in 9m8s
CI/CD Pipeline / Validate - Security (push) Successful in 9m31s
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 / Canary Release to Production (push) Has been skipped
CI/CD Pipeline / Deploy Production (push) Has been skipped
CI/CD Pipeline / Production Browser E2E (push) Has been skipped
将健康检查命令直接写入 Docker 镜像,确保 Watchtower 重建容器时使用正确的健康检查。 修复 Worker 容器持续显示 unhealthy 的问题。
48 lines
1.6 KiB
Docker
Executable File
48 lines
1.6 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
|
||
|
||
# 创建非 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/packages
|
||
ENV PYTHONUNBUFFERED=1
|
||
ENV APP_VERSION=$APP_VERSION
|
||
|
||
# 复制文件(按变化频率从低到高排序,最大化层缓存命中)
|
||
COPY alembic.ini /app/alembic.ini
|
||
COPY migrations/ /app/migrations/
|
||
COPY packages/ /app/packages/
|
||
COPY apps/api/app/config.py /app/apps/api/app/config.py
|
||
COPY apps/api/app/core/ /app/apps/api/app/core/
|
||
|
||
# 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"]
|