-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.dev.yaml
More file actions
256 lines (248 loc) · 7.97 KB
/
docker-compose.dev.yaml
File metadata and controls
256 lines (248 loc) · 7.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
# Docker Compose configuration for Ollama, Open-WebUI, ComfyUI, VRAM Manager, Watchtower, and Grafana
# DEVELOPMENT VERSION - All services including VRAM Manager and Watchtower
#
# Prerequisites:
# - Docker Engine with GPU support (nvidia-docker2)
# - NVIDIA Container Toolkit installed
#
# Usage:
# cp .env.dev .env # If you want to use dev settings
# docker compose -f docker-compose.dev.yaml up -d
networks:
ai-stack:
driver: bridge
name: ai-stack-network
services:
# -------------------------------------------------
# Ollama – LLM inference engine
# -------------------------------------------------
ollama:
image: ${OLLAMA_IMAGE:-ollama/ollama:latest}
container_name: ${OLLAMA_CONTAINER_NAME:-ollama}
restart: ${RESTART_POLICY:-unless-stopped}
networks:
- ai-stack
ports:
- "${OLLAMA_PORT:-11434}:11434"
volumes:
- aistack-ollama_data:/root/.ollama
environment:
- OLLAMA_HOST=${OLLAMA_HOST:-0.0.0.0}
- OLLAMA_ORIGINS=${OLLAMA_ORIGINS:-*}
- OLLAMA_MAX_VRAM=${OLLAMA_MAX_VRAM:-10737418240}
- OLLAMA_MAX_LOADED_MODELS=${OLLAMA_MAX_LOADED_MODELS:-2}
- OLLAMA_NUM_PARALLEL=${OLLAMA_NUM_PARALLEL:-2}
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: all
capabilities: [gpu]
healthcheck:
test: ollama --version || exit 1
interval: 300s
timeout: 10s
retries: 3
start_period: 30s
stop_grace_period: 30s
logging:
driver: json-file
options:
max-size: "10m"
max-file: "3"
# -------------------------------------------------
# Open‑WebUI – Front‑end for Ollama
# -------------------------------------------------
open-webui:
image: ${OPENWEBUI_IMAGE:-ghcr.io/open-webui/open-webui:main}
container_name: ${OPENWEBUI_CONTAINER_NAME:-open-webui}
restart: ${RESTART_POLICY:-unless-stopped}
networks:
- ai-stack
ports:
- "${OPENWEBUI_PORT:-3000}:8080"
volumes:
- aistack-open_webui_data:/app/backend/data
environment:
- OLLAMA_BASE_URL=${OLLAMA_BASE_URL:-http://ollama:11434}
- WEBUI_SECRET_KEY=${WEBUI_SECRET_KEY:-change-this-secret-key}
- WEBUI_AUTH=${WEBUI_AUTH:-true}
- WEBUI_NAME=${WEBUI_NAME:-Open WebUI}
depends_on:
ollama:
condition: service_healthy
healthcheck:
test: ["CMD-SHELL", "wget -q --spider http://localhost:8080/health || exit 1"]
interval: 300s
timeout: 10s
retries: 3
start_period: 45s
stop_grace_period: 30s
logging:
driver: json-file
options:
max-size: "10m"
max-file: "3"
# -------------------------------------------------
# ComfyUI – Stable Diffusion Web UI
# -------------------------------------------------
comfyui:
# TODO: Update to latest runtime tag from https://github.com/SaladTechnologies/comfyui-api/pkgs/container/comfyui-api
image: ${COMFYUI_IMAGE:-ghcr.io/saladtechnologies/comfyui-api:comfy0.3.67-api1.13.3-torch2.8.0-cuda12.8-runtime}
container_name: ${COMFYUI_CONTAINER_NAME:-comfyui}
restart: ${RESTART_POLICY:-unless-stopped}
networks:
- ai-stack
ports:
- "${COMFYUI_PORT:-8188}:8188"
volumes:
- aistack-comfyui_data:/root/.comfyui
- ./data/comfyui/models:/opt/ComfyUI/models
- ./data/comfyui/workflows:/opt/ComfyUI/user/default/workflows
- ./data/comfyui/custom_nodes:/opt/ComfyUI/custom_nodes
environment:
- COMFYUI_PORT=${COMFYUI_INTERNAL_PORT:-8188}
- CLI_ARGS=${COMFYUI_CLI_ARGS:---normalvram}
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: all
capabilities: [gpu]
healthcheck:
test: ["CMD-SHELL", "wget -q --spider http://localhost:8188/system_stats || exit 1"]
interval: 300s
timeout: 10s
retries: 3
start_period: 60s
stop_grace_period: 30s
logging:
driver: json-file
options:
max-size: "10m"
max-file: "3"
# -------------------------------------------------
# Watchtower – Automatic image updates (ENABLED FOR DEVELOPMENT)
#
# ⚠️ Security Note: Watchtower requires docker.sock access
# 📝 Development Use Only: Not recommended for production
# -------------------------------------------------
watchtower:
image: ${WATCHTOWER_IMAGE:-containrrr/watchtower:latest}
container_name: ${WATCHTOWER_CONTAINER_NAME:-watchtower}
restart: ${RESTART_POLICY:-unless-stopped}
networks:
- ai-stack
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
environment:
- WATCHTOWER_CLEANUP=${WATCHTOWER_CLEANUP:-true}
- WATCHTOWER_INCLUDE_STOPPED=${WATCHTOWER_INCLUDE_STOPPED:-false}
- WATCHTOWER_SCHEDULE=${WATCHTOWER_SCHEDULE:-0 0 3 * * *}
- WATCHTOWER_NOTIFICATIONS=${WATCHTOWER_NOTIFICATIONS:-}
- WATCHTOWER_NOTIFICATION_URL=${WATCHTOWER_NOTIFICATION_URL:-}
- WATCHTOWER_DEBUG=${WATCHTOWER_DEBUG:-false}
command:
- --schedule
- "${WATCHTOWER_SCHEDULE:-0 0 3 * * *}"
- --cleanup
deploy:
resources:
limits:
memory: 256M
cpus: '0.5'
logging:
driver: json-file
options:
max-size: "5m"
max-file: "2"
# -------------------------------------------------
# Grafana – Metrics Visualization
# -------------------------------------------------
grafana:
image: ${GRAFANA_IMAGE:-grafana/grafana:latest}
container_name: ${GRAFANA_CONTAINER_NAME:-grafana}
restart: ${RESTART_POLICY:-unless-stopped}
networks:
- ai-stack
ports:
- "${GRAFANA_PORT:-3001}:3000"
volumes:
- aistack-grafana_data:/var/lib/grafana
environment:
- GF_SECURITY_ADMIN_USER=${GF_ADMIN_USER:-admin}
- GF_SECURITY_ADMIN_PASSWORD=${GF_ADMIN_PASSWORD:-admin}
- GF_INSTALL_PLUGINS=${GF_INSTALL_PLUGINS:-}
- GF_SERVER_ROOT_URL=${GF_SERVER_ROOT_URL:-http://localhost:3001}
- GF_ANALYTICS_REPORTING_ENABLED=${GF_ANALYTICS_ENABLED:-false}
- GF_ANALYTICS_CHECK_FOR_UPDATES=${GF_ANALYTICS_UPDATES:-false}
healthcheck:
test: ["CMD-SHELL", "wget -q --spider http://localhost:3000/api/health || exit 1"]
interval: 300s
timeout: 10s
retries: 3
start_period: 30s
stop_grace_period: 10s
deploy:
resources:
limits:
memory: 4G
cpus: '2.0'
logging:
driver: json-file
options:
max-size: "10m"
max-file: "3"
# -------------------------------------------------
# VRAM Manager – Automatic VRAM optimization
# Monitors Ollama model loading and frees ComfyUI VRAM
# to prevent Ollama from falling back to CPU mode.
# -------------------------------------------------
vram-manager:
image: python:3.11-slim
container_name: ${VRAM_MANAGER_CONTAINER_NAME:-aistack-vram-manager}
restart: ${RESTART_POLICY:-unless-stopped}
networks:
- ai-stack
volumes:
- ./scripts:/app/scripts:ro
working_dir: /app
entrypoint: ["/bin/sh", "-c"]
command:
- |
pip install --no-cache-dir requests &&
python /app/scripts/vram_manager.py \
--ollama-url http://aistack-ollama:11434 \
--comfyui-url http://aistack-comfyui:${COMFYUI_INTERNAL_PORT:-8188} \
--check-interval ${VRAM_CHECK_INTERVAL:-5} \
--vram-threshold ${VRAM_THRESHOLD:-75}
depends_on:
ollama:
condition: service_healthy
comfyui:
condition: service_healthy
deploy:
resources:
limits:
memory: 128M
cpus: '0.25'
logging:
driver: json-file
options:
max-size: "5m"
max-file: "2"
volumes:
aistack-ollama_data:
driver: local
name: aistack-ollama_data
aistack-open_webui_data:
driver: local
name: aistack-open_webui_data
aistack-comfyui_data:
driver: local
name: aistack-comfyui_data
aistack-grafana_data:
driver: local
name: aistack-grafana_data