-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
332 lines (302 loc) · 9.43 KB
/
Copy pathdocker-compose.yml
File metadata and controls
332 lines (302 loc) · 9.43 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
329
330
331
332
services:
# -------------------------------------------------------
# PRODUCER (CAMER STREAM INGESTOR)
# -------------------------------------------------------
kafka-producer:
build:
context: .
dockerfile: kafka-producers/Dockerfile.producer
container_name: kafka_producer
network_mode: host
depends_on:
kafka:
condition: service_healthy
environment:
# KAFKA_BROKER: ${KAFKA_BROKER}
KAFKA_BROKER: localhost:29092
KAFKA_TOPIC: ${KAFKA_TOPIC_1}
URL: ${URL}
METRICS_PORT: 8000
ports:
- "8000:8000"
restart: unless-stopped
# -------------------------------------------------------
# CORE INFRASTRUCTURE
# -------------------------------------------------------
zookeeper:
image: confluentinc/cp-zookeeper:7.5.0
container_name: kafka_zookeeper
environment:
ZOOKEEPER_CLIENT_PORT: 2181
ZOOKEEPER_TICK_TIME: 2000
ports:
- "2181:2181"
healthcheck:
test: ["CMD", "echo", "ruok", "|", "nc", "localhost", "2181"]
interval: 5s
timeout: 10s
retries: 5
volumes:
- zookeeper_data:/data
- zookeeper_log:/datalog
kafka:
image: confluentinc/cp-kafka:7.5.0
hostname: kafka
container_name: kafka
ports:
- "9092:9092"
- "29092:29092"
depends_on:
zookeeper:
condition: service_healthy
environment:
KAFKA_BROKER_ID: 1
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092,PLAINTEXT_HOST://localhost:29092
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS: 0
# KAFKA_TOPIC_NAME: ${KAFKA_TOPIC}
KAFKA_AUTO_CREATE_TOPICS_ENABLE: "true"
KAFKA_NUM_PARTITIONS: 3 # Increased from 1 for parallel processing
KAFKA_DEFAULT_REPLICATION_FACTOR: 1
healthcheck:
test: ["CMD", "bash", "-c", "</dev/tcp/localhost/9092 >/dev/null 2>&1"]
interval: 10s
timeout: 10s
retries: 10
volumes:
- kafka_data:/var/lib/kafka/data
kafdrop:
image: obsidiandynamics/kafdrop:3.30.0
container_name: cv_kafdrop
depends_on:
- kafka
environment:
KAFKA_BROKERCONNECT: kafka:9092
ports:
- "19000:9000"
restart: unless-stopped
kafka-preprocessor:
build:
context: .
dockerfile: kafka-consumer/Dockerfile.consumer
depends_on:
kafka:
condition: service_healthy
environment:
KAFKA_BROKER: kafka:9092
KAFKA_INPUT_TOPIC: ${KAFKA_TOPIC_1}
KAFKA_OUTPUT_TOPIC: ${KAFKA_TOPIC_2}
KAFKA_DLQ_TOPIC: dlq-preprocessing-errors
CONSUMER_GROUP_ID: ${CONSUMER_GROUP_ID_1}
YOLO_INPUT_SIZE_WIDTH: 416 # Optimal for CPU: 416x416 balances speed and accuracy
YOLO_INPUT_SIZE_HEIGHT: 416
OUTPUT_JPEG_QUALITY: 90 # Higher quality for better detection (85-95 recommended)
ENABLE_CLAHE: "true" # Enable adaptive contrast for varying lighting conditions
ENABLE_MOTION_DETECTION: "true" # Skip static frames to reduce processing load
MOTION_THRESHOLD: "5.0" # Percentage of pixels changed to consider motion (1-20 typical)
MIN_FRAME_INTERVAL: "0.5" # Minimum seconds between frames (prevent indefinite skipping)
METRICS_PORT: 8001
ports:
- "8001:8001"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8001/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
restart: unless-stopped
# -------------------------------------------------------
# VIEWERS
# -------------------------------------------------------
kafka-viewer:
build:
context: .
dockerfile: view-process/Dockerfile.viewer
depends_on:
kafka:
condition: service_healthy
environment:
KAFKA_BROKER: kafka:9092
KAFKA_TOPIC: ${KAFKA_TOPIC_2}
CONSUMER_GROUP_ID: ${CONSUMER_GROUP_ID_2}
METRICS_PORT: 8004
ports:
- "5000:5000"
- "8004:8004"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:5000/health"]
interval: 30s
timeout: 10s
retries: 3
restart: unless-stopped
detector-viewer:
build:
context: .
dockerfile: view-detection/Dockerfile.viewer-d
depends_on:
kafka:
condition: service_healthy
environment:
KAFKA_BROKER: kafka:9092
KAFKA_TOPIC: ${KAFKA_TOPIC_4}
CONSUMER_GROUP_ID: ${CONSUMER_GROUP_ID_4}
METRICS_PORT: 8005
ports:
- "7000:7000"
- "8005:8005"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:7000/health"]
interval: 30s
timeout: 10s
retries: 3
restart: unless-stopped
yolo-inference:
build:
context: .
dockerfile: model/Dockerfile.model
depends_on:
kafka:
condition: service_healthy
environment:
KAFKA_BROKER: ${KAFKA_BROKER}
KAFKA_INPUT_TOPIC: ${KAFKA_TOPIC_2}
KAFKA_VISUAL_TOPIC: ${KAFKA_TOPIC_4}
KAFKA_DATA_TOPIC: ${KAFKA_TOPIC_3}
KAFKA_DLQ_TOPIC: dlq-inference-errors
CONSUMER_GROUP_ID: ${CONSUMER_GROUP_ID_3}
MODEL_WEIGHTS_PATH: ${MODEL_WEIGHTS_PATH}
DEVICE: "auto" # Auto-detect GPU, fallback to CPU
USE_TRACKING: "false" # Detection only - much faster
INPUT_SIZE: "416" # Match preprocessor output: 416x416 for CPU optimization
CAMERA_ID: ${CAMERA_ID} # Camera identifier for multi-camera deployments
METRICS_PORT: 8002
ports:
- "8002:8002"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8002/health"]
interval: 30s
timeout: 10s
retries: 3
restart: unless-stopped
# # GPU support (uncomment when NVIDIA Container Toolkit is installed)
# # deploy:
# # resources:
# # reservations:
# # devices:
# # - driver: nvidia
# # count: 1
# # capabilities: [gpu]
# # -------------------------------------------------------
# # DATA STORAGE AND MANAGEMENT
# minio-writer:
# build:
# context: .
# dockerfile: minio/Dockerfile.minio-writer
# depends_on:
# kafka:
# condition: service_healthy
# minio:
# condition: service_healthy
# environment:
# KAFKA_BROKER: kafka:9092
# KAFKA_TOPIC: ${KAFKA_TOPIC_3}
# KAFKA_VISUAL_TOPIC: yolo-visual-output
# KAFKA_DLQ_TOPIC: dlq-storage-errors
# CONSUMER_GROUP_ID: ${CONSUMER_GROUP_ID_5}
# FRAMES_CONSUMER_GROUP: frames-saver-group
# MINIO_ENDPOINT: minio:9000
# MINIO_ROOT_USER: minioadmin
# MINIO_ROOT_PASSWORD: minioadmin
# BUCKET_NAME: detections-data
# FRAMES_BUCKET_NAME: annotated-frames
# BATCH_SIZE: 50 # Write a file after 50 detections...
# BATCH_TIMEOUT_SEC: 30 # ...or every 30 seconds
# SAVE_ANNOTATED_FRAMES: "true" # Save annotated frames to MinIO for review
# METRICS_PORT: 8003
# ports:
# - "8003:8003"
# healthcheck:
# test: ["CMD", "curl", "-f", "http://localhost:8003/health"]
# interval: 30s
# timeout: 10s
# retries: 3
# restart: unless-stopped
# minio:
# image: minio/minio
# container_name: minio
# command: server /data --console-address ":9001"
# ports:
# - "9000:9000" # MinIO API
# - "9001:9001" # MinIO Console UI
# volumes:
# - minio_data:/data
# environment:
# MINIO_ROOT_USER: minioadmin
# MINIO_ROOT_PASSWORD: minioadmin
# healthcheck:
# test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
# interval: 30s
# timeout: 20s
# retries: 3
# -------------------------------------------------------
# OBSERVABILITY AND MONITORING
# -------------------------------------------------------
prometheus:
image: prom/prometheus:v2.48.0
container_name: cv_prometheus
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
- '--web.console.libraries=/usr/share/prometheus/console_libraries'
- '--web.console.templates=/usr/share/prometheus/consoles'
ports:
- "9090:9090"
volumes:
- ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
- prometheus_data:/prometheus
restart: unless-stopped
grafana:
image: grafana/grafana:10.2.2
container_name: cv_grafana
ports:
- "3000:3000"
environment:
- GF_SECURITY_ADMIN_USER=admin
- GF_SECURITY_ADMIN_PASSWORD=admin
- GF_USERS_ALLOW_SIGN_UP=false
volumes:
- grafana_data:/var/lib/grafana
- ./grafana/provisioning:/etc/grafana/provisioning
depends_on:
- prometheus
restart: unless-stopped
# -------------------------------------------------------
# MANAGEMENT INTERFACES
# -------------------------------------------------------
# portainer:
# image: portainer/portainer-ce:latest
# container_name: cv_portainer
# restart: always
# ports:
# - "9443:9443"
# volumes:
# - /var/run/docker.sock:/var/run/docker.sock
# - portainer_data:/data
# trino-coordinator:
# image: trinodb/trino:402
# container_name: trino-coordinator
# ports:
# - "8088:8080"
# volumes:
# - ./trino/etc:/etc/trino
volumes:
zookeeper_data:
zookeeper_log:
kafka_data:
portainer_data:
minio_data:
prometheus_data:
grafana_data: