-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathdocker-compose.yaml
More file actions
328 lines (310 loc) · 10.2 KB
/
Copy pathdocker-compose.yaml
File metadata and controls
328 lines (310 loc) · 10.2 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
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
networks:
openlpr-network:
driver: bridge
volumes:
lpr_data:
driver: local
lpr_media:
driver: local
lpr_static:
driver: local
model_files:
driver: local
prometheus_data:
driver: local
grafana_data:
driver: local
lpr_metrics:
driver: local
services:
# Core Services
lpr-app:
env_file:
- .env.llamacpp
image: ghcr.io/faisalthaheem/open-lpr:latest
container_name: lpr-app
volumes:
# SQLite database persistence
- ./container-data:/app/data
# Media files persistence (uploaded and processed images)
- ./container-media:/app/media
# Static files (optional - for development)
- ./staticfiles:/app/staticfiles
# Metrics persistence
- ./container-metrics:/app/metrics
# Run as root initially for setup, then entrypoint switches to django user
user: "0:0"
environment:
# Django Settings
- SECRET_KEY=${SECRET_KEY:-django-insecure-change-me-in-production}
- DEBUG=${DEBUG:-False}
- ALLOWED_HOSTS=${ALLOWED_HOSTS:-localhost,127.0.0.1,0.0.0.0,lpr-app}
- CORS_ALLOWED_ORIGINS=${CORS_ALLOWED_ORIGINS:-http://localhost:3000}
- CORS_ALLOW_PRIVATE_NETWORK=${CORS_ALLOW_PRIVATE_NETWORK:-False}
# Rate Limiting
- RATE_LIMIT_ENABLE=${RATE_LIMIT_ENABLE:-True}
- RATE_LIMIT_RATE=${RATE_LIMIT_RATE:-2/min}
- RATE_LIMIT_EXCLUDE_PATHS=${RATE_LIMIT_EXCLUDE_PATHS:-/health/,/api/v1/health-light/}
- RATE_LIMIT_INCLUDE_PATHS=${RATE_LIMIT_INCLUDE_PATHS:-/api/v1/ocr/}
# Qwen3-VL API Configuration - Updated to use local LlamaCpp service
- QWEN_API_KEY=${QWEN_API_KEY:-sk-llamacpp-local}
- QWEN_BASE_URL=${QWEN_BASE_URL:-http://llamacpp-cpu:8000/v1}
- QWEN_MODEL=${QWEN_MODEL:-gpt-4-vision-preview} # Model alias for compatibility
# File Upload Settings
- UPLOAD_FILE_MAX_SIZE=${UPLOAD_FILE_MAX_SIZE:-10485760}
- MAX_BATCH_SIZE=${MAX_BATCH_SIZE:-10}
# Database Configuration
- DATABASE_PATH=/app/data/db.sqlite3
# Metrics persistence
- METRICS_FILE_PATH=/app/metrics/metrics_state.json
# Prometheus URL for availability proxy
- PROMETHEUS_URL=${PROMETHEUS_URL:-http://prometheus:9090}
# Scheduler - auto-detected under Gunicorn, set explicitly if needed
# - RUN_SCHEDULER=true
# Canary Configuration
- CANARY_HEADER_NAME=${CANARY_HEADER_NAME:-X-Canary-Request}
- CANARY_HEADER_VALUE=${CANARY_HEADER_VALUE:-true}
- CANARY_ENABLED=${CANARY_ENABLED:-true}
# Optional: Superuser creation
- DJANGO_SUPERUSER_USERNAME=${DJANGO_SUPERUSER_USERNAME:-}
- DJANGO_SUPERUSER_EMAIL=${DJANGO_SUPERUSER_EMAIL:-}
- DJANGO_SUPERUSER_PASSWORD=${DJANGO_SUPERUSER_PASSWORD:-}
networks:
- openlpr-network
# Port is configurable via environment variable
ports:
- "${LPR_APP_PORT:-8000}:8000"
restart: unless-stopped
healthcheck:
test: ["CMD", "python", "manage.py", "check"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
entrypoint: ["./docker-entrypoint.sh"]
command: ["gunicorn", "--bind", "0.0.0.0:8000", "--workers", "1", "--timeout", "120", "lpr_project.wsgi:application"]
profiles:
- core
spa:
image: ghcr.io/faisalthaheem/open-lpr-spa:latest
container_name: spa
environment:
- BACKEND_API_URL=${BACKEND_API_URL:-http://lpr-app:8000}
- PORT=${SPA_PORT:-3000}
ports:
- "${SPA_PORT:-3000}:${SPA_PORT:-3000}"
networks:
- openlpr-network
restart: unless-stopped
healthcheck:
test: ["CMD-SHELL", "wget --spider --quiet http://127.0.0.1:${SPA_PORT:-3000} || exit 1"]
interval: 30s
timeout: 10s
retries: 3
start_period: 30s
profiles:
- core
prometheus:
# Use custom image with config baked in
image: ghcr.io/faisalthaheem/open-lpr-prometheus:latest
container_name: prometheus
# Port is configurable via environment variable
ports:
- "${PROMETHEUS_PORT:-9090}:9090"
volumes:
# Only need data volume, no config mount needed
- prometheus_data:/prometheus
networks:
- openlpr-network
restart: unless-stopped
healthcheck:
test: ["CMD-SHELL", "wget --spider --quiet http://127.0.0.1:9090/-/healthy || exit 1"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
profiles:
- core
grafana:
# Use custom image with provisioning baked in
image: ghcr.io/faisalthaheem/open-lpr-grafana:latest
container_name: grafana
# Port is configurable via environment variable
ports:
- "${GRAFANA_PORT:-3000}:3000"
environment:
- GF_SECURITY_ADMIN_USER=${GRAFANA_USER:-admin}
- GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_PASSWORD:-admin}
- GF_USERS_ALLOW_SIGN_UP=false
volumes:
# Only need data volume, no provisioning mount needed
- grafana_data:/var/lib/grafana
networks:
- openlpr-network
restart: unless-stopped
healthcheck:
test: ["CMD-SHELL", "wget --spider --quiet http://127.0.0.1:3000/api/health || exit 1"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
profiles:
- core
blackbox-exporter:
# Use custom image with config baked in
image: ghcr.io/faisalthaheem/open-lpr-blackbox:latest
container_name: blackbox-exporter
# Port is configurable via environment variable
ports:
- "${BLACKBOX_PORT:-9115}:9115"
networks:
- openlpr-network
restart: unless-stopped
healthcheck:
test: ["CMD-SHELL", "wget --spider --quiet http://127.0.0.1:9115 || exit 1"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
profiles:
- core
lpr-canary:
env_file:
- .env.llamacpp
image: ghcr.io/faisalthaheem/open-lpr-canary:latest
container_name: lpr-canary
# Port is configurable via environment variable
ports:
- "${CANARY_PORT:-9100}:9100"
environment:
- LPR_API_URL=${LPR_API_URL:-http://lpr-app:8000/api/v1/ocr/}
- CANARY_HEADER_NAME=${CANARY_HEADER_NAME:-X-Canary-Request}
- CANARY_HEADER_VALUE=${CANARY_HEADER_VALUE:-true}
- CANARY_INTERVAL=${CANARY_INTERVAL:-900}
- PROMETHEUS_PORT=9100
networks:
- openlpr-network
restart: unless-stopped
healthcheck:
test: ["CMD-SHELL", "wget --spider --quiet http://localhost:9100/metrics || exit 1"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
profiles:
- core
# Inference Services
llamacpp-cpu:
env_file:
- .env.llamacpp
image: ghcr.io/ggml-org/llama.cpp:server
container_name: llamacpp-cpu
ports:
- "8001:8000" # Use 8001 to avoid conflict with OpenLPR on 8000
volumes:
# Model storage
- ./model_files:/models
- ./model_files_cache:/root/.cache/
environment:
# Model configuration
- LLAMA_ARG_MODEL=/models/${MODEL_FILE:-Qwen3-VL-4B-Instruct-Q5_K_M.gguf}
- LLAMA_ARG_HF_REPO=${MODEL_REPO:-unsloth/Qwen3-VL-4B-Instruct-GGUF}
- LLAMA_ARG_HF_FILE=${MODEL_FILE:-Qwen3-VL-4B-Instruct-Q5_K_M.gguf}
- LLAMA_ARG_MMPROJ_URL=${MMPROJ_URL:-https://huggingface.co/unsloth/Qwen3-VL-4B-Instruct-GGUF/resolve/main/mmproj-BF16.gguf}
- HF_TOKEN=${HF_TOKEN}
- LLAMA_ARG_JINJA=1
- LLAMA_ARG_CHAT_TEMPLATE=chatml
- LLAMA_ARG_HOST=0.0.0.0
- LLAMA_ARG_PORT=8000
networks:
- openlpr-network
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
profiles:
- cpu
llamacpp-amd-vulkan:
env_file:
- .env.llamacpp
image: ghcr.io/ggml-org/llama.cpp:server-vulkan
container_name: llamacpp-amd-vulkan
ports:
- "8001:8000" # Use 8001 to avoid conflict with OpenLPR on 8000
volumes:
# Model storage
- ./model_files:/models
- ./model_files_cache:/root/.cache/
environment:
# Model configuration
- LLAMA_ARG_MODEL=/models/${MODEL_FILE:-Qwen3-VL-4B-Instruct-Q5_K_M.gguf}
- LLAMA_ARG_HF_REPO=${MODEL_REPO:-unsloth/Qwen3-VL-4B-Instruct-GGUF}
- LLAMA_ARG_HF_FILE=${MODEL_FILE:-Qwen3-VL-4B-Instruct-Q5_K_M.gguf}
- LLAMA_ARG_MMPROJ_URL=${MMPROJ_URL:-https://huggingface.co/unsloth/Qwen3-VL-4B-Instruct-GGUF/resolve/main/mmproj-BF16.gguf}
- HF_TOKEN=${HF_TOKEN}
- LLAMA_ARG_JINJA=1
- LLAMA_ARG_CHAT_TEMPLATE=chatml
- LLAMA_ARG_HOST=0.0.0.0
- LLAMA_ARG_PORT=8000
- LLAMA_ARG_DEVICE=vulkan0
networks:
- openlpr-network
devices:
- /dev/kfd
- /dev/dri
security_opt:
- seccomp=unconfined
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
profiles:
- amd-vulkan
llamacpp-nvidia-cuda:
env_file:
- .env.llamacpp
image: ghcr.io/ggml-org/llama.cpp:server-cuda
container_name: llamacpp-nvidia-cuda
ports:
- "8001:8000" # Use 8001 to avoid conflict with OpenLPR on 8000
volumes:
# Model storage
- ./model_files:/models
- ./model_files_cache:/root/.cache/
environment:
# Model configuration
- LLAMA_ARG_MODEL=/models/${MODEL_FILE:-Qwen3-VL-4B-Instruct-Q5_K_M.gguf}
- LLAMA_ARG_HF_REPO=${MODEL_REPO:-unsloth/Qwen3-VL-4B-Instruct-GGUF}
- LLAMA_ARG_HF_FILE=${MODEL_FILE:-Qwen3-VL-4B-Instruct-Q5_K_M.gguf}
- LLAMA_ARG_MMPROJ_URL=${MMPROJ_URL:-https://huggingface.co/unsloth/Qwen3-VL-4B-Instruct-GGUF/resolve/main/mmproj-BF16.gguf}
- HF_TOKEN=${HF_TOKEN}
- LLAMA_ARG_JINJA=1
- LLAMA_ARG_CHAT_TEMPLATE=chatml
- LLAMA_ARG_HOST=0.0.0.0
- LLAMA_ARG_PORT=8000
- LLAMA_ARG_N_GPUS=1
- LLAMA_ARG_GPU_LAYERS=99
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: 1
capabilities: [gpu]
networks:
- openlpr-network
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
profiles:
- nvidia-cuda