Create docker/docker_compose.yml
Browse files- docker/docker_compose.yml +183 -0
docker/docker_compose.yml
ADDED
@@ -0,0 +1,183 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
version: '3.8'
|
2 |
+
|
3 |
+
services:
|
4 |
+
# Main application with GPU support
|
5 |
+
backgroundfx-gpu:
|
6 |
+
build:
|
7 |
+
context: ..
|
8 |
+
dockerfile: docker/Dockerfile
|
9 |
+
image: backgroundfx-pro:gpu
|
10 |
+
container_name: backgroundfx-gpu
|
11 |
+
runtime: nvidia
|
12 |
+
environment:
|
13 |
+
- NVIDIA_VISIBLE_DEVICES=0
|
14 |
+
- CUDA_VISIBLE_DEVICES=0
|
15 |
+
- GRADIO_SERVER_NAME=0.0.0.0
|
16 |
+
- GRADIO_SERVER_PORT=7860
|
17 |
+
- MODEL_CACHE_DIR=/app/models
|
18 |
+
- TORCH_HOME=/app/models/.cache
|
19 |
+
- LOG_LEVEL=INFO
|
20 |
+
- MAX_WORKERS=4
|
21 |
+
volumes:
|
22 |
+
- model-cache:/app/models
|
23 |
+
- uploads:/app/uploads
|
24 |
+
- outputs:/app/outputs
|
25 |
+
- ./config:/app/config:ro
|
26 |
+
ports:
|
27 |
+
- "7860:7860" # Gradio UI
|
28 |
+
- "8000:8000" # REST API
|
29 |
+
networks:
|
30 |
+
- backgroundfx-net
|
31 |
+
healthcheck:
|
32 |
+
test: ["CMD", "curl", "-f", "http://localhost:7860/health"]
|
33 |
+
interval: 30s
|
34 |
+
timeout: 10s
|
35 |
+
retries: 3
|
36 |
+
start_period: 60s
|
37 |
+
deploy:
|
38 |
+
resources:
|
39 |
+
reservations:
|
40 |
+
devices:
|
41 |
+
- driver: nvidia
|
42 |
+
count: 1
|
43 |
+
capabilities: [gpu]
|
44 |
+
limits:
|
45 |
+
memory: 16G
|
46 |
+
cpus: '8'
|
47 |
+
restart: unless-stopped
|
48 |
+
|
49 |
+
# CPU-only variant for development/testing
|
50 |
+
backgroundfx-cpu:
|
51 |
+
build:
|
52 |
+
context: ..
|
53 |
+
dockerfile: docker/Dockerfile.cpu
|
54 |
+
image: backgroundfx-pro:cpu
|
55 |
+
container_name: backgroundfx-cpu
|
56 |
+
profiles: ["cpu"]
|
57 |
+
environment:
|
58 |
+
- GRADIO_SERVER_NAME=0.0.0.0
|
59 |
+
- GRADIO_SERVER_PORT=7860
|
60 |
+
- MODEL_CACHE_DIR=/app/models
|
61 |
+
- TORCH_HOME=/app/models/.cache
|
62 |
+
- DEVICE=cpu
|
63 |
+
- LOG_LEVEL=INFO
|
64 |
+
volumes:
|
65 |
+
- model-cache:/app/models
|
66 |
+
- uploads:/app/uploads
|
67 |
+
- outputs:/app/outputs
|
68 |
+
- ./config:/app/config:ro
|
69 |
+
ports:
|
70 |
+
- "7861:7860" # Different port for CPU version
|
71 |
+
networks:
|
72 |
+
- backgroundfx-net
|
73 |
+
deploy:
|
74 |
+
resources:
|
75 |
+
limits:
|
76 |
+
memory: 8G
|
77 |
+
cpus: '4'
|
78 |
+
restart: unless-stopped
|
79 |
+
|
80 |
+
# Redis for caching and job queue
|
81 |
+
redis:
|
82 |
+
image: redis:7-alpine
|
83 |
+
container_name: backgroundfx-redis
|
84 |
+
command: redis-server --appendonly yes
|
85 |
+
volumes:
|
86 |
+
- redis-data:/data
|
87 |
+
ports:
|
88 |
+
- "6379:6379"
|
89 |
+
networks:
|
90 |
+
- backgroundfx-net
|
91 |
+
healthcheck:
|
92 |
+
test: ["CMD", "redis-cli", "ping"]
|
93 |
+
interval: 10s
|
94 |
+
timeout: 5s
|
95 |
+
retries: 5
|
96 |
+
restart: unless-stopped
|
97 |
+
|
98 |
+
# Nginx reverse proxy
|
99 |
+
nginx:
|
100 |
+
image: nginx:alpine
|
101 |
+
container_name: backgroundfx-nginx
|
102 |
+
profiles: ["production"]
|
103 |
+
volumes:
|
104 |
+
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
|
105 |
+
- ./nginx/ssl:/etc/nginx/ssl:ro
|
106 |
+
- nginx-cache:/var/cache/nginx
|
107 |
+
ports:
|
108 |
+
- "80:80"
|
109 |
+
- "443:443"
|
110 |
+
networks:
|
111 |
+
- backgroundfx-net
|
112 |
+
depends_on:
|
113 |
+
- backgroundfx-gpu
|
114 |
+
restart: unless-stopped
|
115 |
+
|
116 |
+
# Model downloader service
|
117 |
+
model-downloader:
|
118 |
+
build:
|
119 |
+
context: ..
|
120 |
+
dockerfile: docker/Dockerfile.models
|
121 |
+
image: backgroundfx-pro:models
|
122 |
+
container_name: backgroundfx-models
|
123 |
+
profiles: ["setup"]
|
124 |
+
environment:
|
125 |
+
- MODEL_DIR=/models
|
126 |
+
volumes:
|
127 |
+
- model-cache:/models
|
128 |
+
command: ["python", "download_models.py", "--all"]
|
129 |
+
networks:
|
130 |
+
- backgroundfx-net
|
131 |
+
|
132 |
+
# Monitoring with Prometheus
|
133 |
+
prometheus:
|
134 |
+
image: prom/prometheus:latest
|
135 |
+
container_name: backgroundfx-prometheus
|
136 |
+
profiles: ["monitoring"]
|
137 |
+
volumes:
|
138 |
+
- ./monitoring/prometheus.yml:/etc/prometheus/prometheus.yml:ro
|
139 |
+
- prometheus-data:/prometheus
|
140 |
+
ports:
|
141 |
+
- "9090:9090"
|
142 |
+
networks:
|
143 |
+
- backgroundfx-net
|
144 |
+
restart: unless-stopped
|
145 |
+
|
146 |
+
# Grafana for visualization
|
147 |
+
grafana:
|
148 |
+
image: grafana/grafana:latest
|
149 |
+
container_name: backgroundfx-grafana
|
150 |
+
profiles: ["monitoring"]
|
151 |
+
environment:
|
152 |
+
- GF_SECURITY_ADMIN_PASSWORD=admin
|
153 |
+
- GF_INSTALL_PLUGINS=redis-datasource
|
154 |
+
volumes:
|
155 |
+
- grafana-data:/var/lib/grafana
|
156 |
+
- ./monitoring/grafana:/etc/grafana/provisioning:ro
|
157 |
+
ports:
|
158 |
+
- "3000:3000"
|
159 |
+
networks:
|
160 |
+
- backgroundfx-net
|
161 |
+
depends_on:
|
162 |
+
- prometheus
|
163 |
+
restart: unless-stopped
|
164 |
+
|
165 |
+
networks:
|
166 |
+
backgroundfx-net:
|
167 |
+
driver: bridge
|
168 |
+
|
169 |
+
volumes:
|
170 |
+
model-cache:
|
171 |
+
driver: local
|
172 |
+
uploads:
|
173 |
+
driver: local
|
174 |
+
outputs:
|
175 |
+
driver: local
|
176 |
+
redis-data:
|
177 |
+
driver: local
|
178 |
+
nginx-cache:
|
179 |
+
driver: local
|
180 |
+
prometheus-data:
|
181 |
+
driver: local
|
182 |
+
grafana-data:
|
183 |
+
driver: local
|