Dockerfile 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. # 国内 Jenkins 默认走 DaoCloud 公共镜像代理(完整代理 docker.io/library),避免拉取超时
  2. # 可覆盖: docker build --build-arg NODE_IMAGE=node:20-alpine ...
  3. ARG NODE_IMAGE=docker.m.daocloud.io/library/node:20-alpine
  4. ARG PYTHON_IMAGE=docker.m.daocloud.io/library/python:3.11-slim
  5. # Stage 1: build frontend
  6. FROM ${NODE_IMAGE} AS web-builder
  7. WORKDIR /app/web
  8. COPY web/package.json web/package-lock.json ./
  9. RUN npm config set registry https://registry.npmmirror.com \
  10. && npm ci
  11. COPY web/ ./
  12. RUN npm run build
  13. # Stage 2: Python runtime
  14. FROM ${PYTHON_IMAGE}
  15. WORKDIR /app
  16. ENV PYTHONUNBUFFERED=1 \
  17. PYTHONDONTWRITEBYTECODE=1 \
  18. PIP_NO_CACHE_DIR=1 \
  19. PIP_DISABLE_PIP_VERSION_CHECK=1 \
  20. TZ=Asia/Shanghai \
  21. SCHEDULER_TIMEZONE=Asia/Shanghai \
  22. SCHEDULER_CRON_HOUR=15 \
  23. SCHEDULER_CRON_MINUTE=0 \
  24. PIPELINE_WORKER_PROCESSES=4 \
  25. PIPELINE_MAX_ACTIVE_STEPS=4 \
  26. PIPELINE_REQUIRE_SCHEDULER=true \
  27. PIPELINE_REQUIRE_SECURE_COOKIE=true \
  28. RUN_RUNTIME_PREFLIGHT=true \
  29. FIND_AGENT_TIMEOUT_SECONDS=600 \
  30. MYSQL_CONNECTION_BUDGET=40
  31. RUN sed -i 's|deb.debian.org|mirrors.aliyun.com|g; s|security.debian.org|mirrors.aliyun.com|g' /etc/apt/sources.list.d/debian.sources 2>/dev/null || \
  32. sed -i 's|deb.debian.org|mirrors.aliyun.com|g; s|security.debian.org|mirrors.aliyun.com|g' /etc/apt/sources.list 2>/dev/null || true
  33. RUN apt-get update \
  34. && apt-get install -y --no-install-recommends gcc ffmpeg supervisor \
  35. && ffmpeg -version >/dev/null \
  36. && ffprobe -version >/dev/null \
  37. && ffmpeg -hide_banner -loglevel error \
  38. -f lavfi -i testsrc=duration=2:size=160x120:rate=10 \
  39. -t 2 -c:v libx264 -pix_fmt yuv420p /tmp/verify_src.mp4 \
  40. && ffmpeg -hide_banner -loglevel error -y \
  41. -i /tmp/verify_src.mp4 -t 1 -c copy /tmp/verify_clip.mp4 \
  42. && test -s /tmp/verify_clip.mp4 \
  43. && rm -f /tmp/verify_src.mp4 /tmp/verify_clip.mp4 \
  44. && rm -rf /var/lib/apt/lists/*
  45. COPY pyproject.toml requirements.txt README.md ./
  46. COPY supply_agent/ supply_agent/
  47. COPY supply_infra/ supply_infra/
  48. COPY agents/ agents/
  49. COPY api/ api/
  50. COPY alembic.ini ./
  51. COPY alembic/ alembic/
  52. COPY deploy/ deploy/
  53. COPY scripts/verify_video_truncate_runtime.py scripts/
  54. COPY scripts/container-entrypoint.sh scripts/
  55. RUN test -s agents/demand_belong_category_agent/prompt/system_prompt.md \
  56. && test -s agents/demand_grade_agent/prompt/system_prompt.md \
  57. && test -s agents/demand_video_expand_agent/prompt/system_prompt.md \
  58. && pip install -i https://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com ".[odps]" \
  59. && python scripts/verify_video_truncate_runtime.py \
  60. && chmod +x scripts/container-entrypoint.sh
  61. COPY --from=web-builder /app/web/dist ./web/dist
  62. EXPOSE 8080
  63. HEALTHCHECK --interval=30s --timeout=5s --start-period=90s --retries=3 \
  64. CMD python -c "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8080/health/ready', timeout=4).read()" || exit 1
  65. STOPSIGNAL SIGTERM
  66. ENTRYPOINT ["/app/scripts/container-entrypoint.sh"]