docker-compose.yml 3.8 KB

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