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