Dockerfile 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. # Pixelle-Video Docker Image
  2. # Based on Python 3.11 slim for smaller image size
  3. FROM python:3.11-slim
  4. # Build arguments for mirror configuration
  5. # USE_CN_MIRROR: whether to use China mirrors (true/false)
  6. ARG USE_CN_MIRROR=false
  7. # Set working directory
  8. WORKDIR /app
  9. # Replace apt sources with China mirrors if needed
  10. # Debian 12 uses DEB822 format in /etc/apt/sources.list.d/debian.sources
  11. RUN if [ "$USE_CN_MIRROR" = "true" ]; then \
  12. sed -i 's|deb.debian.org|mirrors.aliyun.com|g' /etc/apt/sources.list.d/debian.sources && \
  13. sed -i 's|security.debian.org|mirrors.aliyun.com|g' /etc/apt/sources.list.d/debian.sources; \
  14. fi
  15. # Install system dependencies
  16. # - curl: for health checks and downloads
  17. # - ffmpeg: for video/audio processing
  18. # - fonts-noto-cjk: for CJK character support
  19. RUN apt-get update && apt-get install -y \
  20. curl \
  21. ffmpeg \
  22. fonts-noto-cjk \
  23. && rm -rf /var/lib/apt/lists/*
  24. # Install uv package manager
  25. # For China: use pip to install uv from mirror (faster and more stable)
  26. # For International: use official installer script
  27. RUN if [ "$USE_CN_MIRROR" = "true" ]; then \
  28. pip install --no-cache-dir -i https://pypi.tuna.tsinghua.edu.cn/simple/ uv; \
  29. else \
  30. curl -LsSf https://astral.sh/uv/install.sh | sh; \
  31. fi
  32. ENV PATH="/root/.local/bin:$PATH"
  33. RUN uv --version
  34. # Copy dependency files and source code for building
  35. # Note: pixelle_video is needed for hatchling to build the package
  36. COPY pyproject.toml uv.lock README.md ./
  37. COPY pixelle_video ./pixelle_video
  38. # Create virtual environment and install dependencies
  39. # Use -i flag to specify mirror when USE_CN_MIRROR=true
  40. RUN export UV_HTTP_TIMEOUT=300 && \
  41. uv venv && \
  42. if [ "$USE_CN_MIRROR" = "true" ]; then \
  43. uv pip install -e . -i https://pypi.tuna.tsinghua.edu.cn/simple; \
  44. else \
  45. uv pip install -e .; \
  46. fi && \
  47. uv run playwright install --with-deps chromium
  48. # Copy rest of application code
  49. COPY api ./api
  50. COPY web ./web
  51. COPY bgm ./bgm
  52. COPY templates ./templates
  53. COPY workflows ./workflows
  54. COPY resources ./resources
  55. COPY docs/images ./docs/images
  56. COPY docs/FAQ*.md ./docs/
  57. # Create output, data and temp directories
  58. RUN mkdir -p /app/output /app/data /app/temp
  59. # Expose ports
  60. # 8000: API service
  61. # 8501: Web UI service
  62. EXPOSE 8000 8501
  63. # Default command (can be overridden in docker-compose)
  64. CMD ["uv", "run", "python", "api/app.py"]