| 1 | version: '3.8' |
| 2 | |
| 3 | # Build Arguments Configuration |
| 4 | # You can override these by setting environment variables before running docker-compose |
| 5 | # |
| 6 | # Example for China environment (auto uses Tsinghua mirror): |
| 7 | # USE_CN_MIRROR=true docker-compose up -d |
| 8 | # |
| 9 | # Example for international environment (default): |
| 10 | # docker-compose up -d |
| 11 | |
| 12 | services: |
| 13 | # Init Service - Ensures config.yaml exists before other services start |
| 14 | # This fixes the Docker issue where mounting a non-existent file creates a directory |
| 15 | init: |
| 16 | image: alpine:latest |
| 17 | volumes: |
| 18 | - ./:/workspace |
| 19 | command: > |
| 20 | sh -c ' |
| 21 | if [ -d /workspace/config.yaml ]; then |
| 22 | echo "⚠️ config.yaml is a directory, removing it..."; |
| 23 | rm -rf /workspace/config.yaml; |
| 24 | fi; |
| 25 | if [ ! -f /workspace/config.yaml ] && [ -f /workspace/config.example.yaml ]; then |
| 26 | echo "📋 Creating config.yaml from config.example.yaml..."; |
| 27 | cp /workspace/config.example.yaml /workspace/config.yaml; |
| 28 | echo "✅ config.yaml created successfully!"; |
| 29 | else |
| 30 | echo "✅ config.yaml already exists."; |
| 31 | fi |
| 32 | ' |
| 33 | restart: "no" |
| 34 | |
| 35 | # API Service - FastAPI backend |
| 36 | api: |
| 37 | build: |
| 38 | context: . |
| 39 | dockerfile: Dockerfile |
| 40 | args: |
| 41 | USE_CN_MIRROR: ${USE_CN_MIRROR:-false} |
| 42 | container_name: pixelle-video-api |
| 43 | command: .venv/bin/python api/app.py --host 0.0.0.0 --port 8000 |
| 44 | depends_on: |
| 45 | init: |
| 46 | condition: service_completed_successfully |
| 47 | ports: |
| 48 | - "8000:8000" |
| 49 | volumes: |
| 50 | # Mount config file (read-write to allow saving from Web UI) |
| 51 | # Note: init service auto-creates config.yaml from config.example.yaml if not exists |
| 52 | - ./config.yaml:/app/config.yaml |
| 53 | # Mount data directories for persistence |
| 54 | # data/ contains: users/, bgm/, templates/, workflows/ (custom resources) |
| 55 | - ./data:/app/data |
| 56 | - ./output:/app/output |
| 57 | # Note: Default resources (bgm/, templates/, workflows/) are baked into the image |
| 58 | # Custom resources in data/* will override defaults |
| 59 | environment: |
| 60 | - TZ=Asia/Shanghai |
| 61 | restart: unless-stopped |
| 62 | healthcheck: |
| 63 | test: ["CMD", "curl", "-f", "http://localhost:8000/health"] |
| 64 | interval: 30s |
| 65 | timeout: 10s |
| 66 | retries: 3 |
| 67 | start_period: 10s |
| 68 | logging: |
| 69 | driver: "json-file" |
| 70 | options: |
| 71 | max-size: "10m" |
| 72 | max-file: "3" |
| 73 | networks: |
| 74 | - pixelle-network |
| 75 | |
| 76 | # Web UI Service - Streamlit frontend |
| 77 | web: |
| 78 | build: |
| 79 | context: . |
| 80 | dockerfile: Dockerfile |
| 81 | args: |
| 82 | USE_CN_MIRROR: ${USE_CN_MIRROR:-false} |
| 83 | container_name: pixelle-video-web |
| 84 | command: .venv/bin/streamlit run web/app.py --server.port 8501 --server.address 0.0.0.0 |
| 85 | depends_on: |
| 86 | init: |
| 87 | condition: service_completed_successfully |
| 88 | ports: |
| 89 | - "8501:8501" |
| 90 | volumes: |
| 91 | # Mount config file (read-write to allow saving from Web UI) |
| 92 | # Note: init service auto-creates config.yaml from config.example.yaml if not exists |
| 93 | - ./config.yaml:/app/config.yaml |
| 94 | # Mount data directories for persistence |
| 95 | # data/ contains: users/, bgm/, templates/, workflows/ (custom resources) |
| 96 | - ./data:/app/data |
| 97 | - ./output:/app/output |
| 98 | # Note: Default resources (bgm/, templates/, workflows/) are baked into the image |
| 99 | # Custom resources in data/* will override defaults |
| 100 | environment: |
| 101 | - TZ=Asia/Shanghai |
| 102 | - STREAMLIT_SERVER_PORT=8501 |
| 103 | - STREAMLIT_SERVER_ADDRESS=0.0.0.0 |
| 104 | - STREAMLIT_BROWSER_GATHER_USAGE_STATS=false |
| 105 | restart: unless-stopped |
| 106 | healthcheck: |
| 107 | test: ["CMD", "curl", "-f", "http://localhost:8501/_stcore/health"] |
| 108 | interval: 30s |
| 109 | timeout: 10s |
| 110 | retries: 3 |
| 111 | start_period: 15s |
| 112 | logging: |
| 113 | driver: "json-file" |
| 114 | options: |
| 115 | max-size: "10m" |
| 116 | max-file: "3" |
| 117 | networks: |
| 118 | - pixelle-network |
| 119 | |
| 120 | networks: |
| 121 | pixelle-network: |
| 122 | driver: bridge |
| 123 | |
| 124 |