-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
510 lines (485 loc) · 15.7 KB
/
Copy pathdocker-compose.yml
File metadata and controls
510 lines (485 loc) · 15.7 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
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
# ============================================================================
# UIP - Urban Intelligence Platform
# Copyright (c) 2025 UIP Team. All rights reserved.
# https://github.com/UIP-Urban-Intelligence-Platform/UIP-Urban_Intelligence_Platform
#
# SPDX-License-Identifier: MIT
# ============================================================================
# File: docker-compose.yml
# Module: Docker Compose Test Stack
# Author: Nguyen Nhat Quang
# Created: 2025-11-24
# Version: 1.0.0
# License: MIT
#
# Description:
# Complete integration testing environment for all agents
# ============================================================================
services:
# ==========================================================================
# CORE DATA STORES
# ==========================================================================
# Neo4j - Property Graph Database
neo4j:
image: neo4j:5.12.0
container_name: test-neo4j
ports:
- "7474:7474" # HTTP
- "7687:7687" # Bolt
environment:
- NEO4J_AUTH=neo4j/test12345
- NEO4J_PLUGINS=["apoc"]
- NEO4J_server_memory_heap_max__size=512M
- NEO4J_server_memory_pagecache_size=256M
- NEO4J_dbms_security_procedures_unrestricted=apoc.*
- NEO4J_dbms_security_procedures_allowlist=apoc.*
volumes:
- neo4j_test_data:/data
healthcheck:
test:
[
"CMD-SHELL",
"cypher-shell -u neo4j -p test12345 'RETURN 1' > /dev/null 2>&1 || exit 1",
]
interval: 15s
timeout: 15s
retries: 20
start_period: 120s # Neo4j needs time to start, install APOC plugin, and initialize
restart: unless-stopped
networks:
- test-network
# Apache Jena Fuseki - Triplestore
fuseki:
image: stain/jena-fuseki:latest
container_name: test-fuseki
ports:
- "3030:3030"
environment:
- ADMIN_PASSWORD=test_admin
- JVM_ARGS=-Xmx512m -Xms256m
volumes:
- fuseki_test_data:/fuseki
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3030/$$/ping"]
interval: 10s
timeout: 5s
retries: 12
start_period: 30s # JVM needs time to start
restart: unless-stopped
networks:
- test-network
# Redis - Cache and Message Broker
redis:
image: redis:7-alpine
container_name: test-redis
ports:
- "6379:6379"
command: redis-server --requirepass test_redis_pass --maxmemory 256mb --maxmemory-policy allkeys-lru --save "" --appendonly no
volumes:
- redis_test_data:/data
healthcheck:
test: ["CMD", "redis-cli", "--raw", "incr", "ping"]
interval: 10s
timeout: 5s
retries: 5
restart: unless-stopped
networks:
- test-network
# MongoDB - NGSI-LD Entity Storage
mongodb:
image: mongo:7.0
container_name: test-mongodb
ports:
- "27017:27017"
environment:
- MONGO_INITDB_ROOT_USERNAME=admin
- MONGO_INITDB_ROOT_PASSWORD=mongodb_test_pass
- MONGO_INITDB_DATABASE=ngsi_ld_entities
volumes:
- mongodb_test_data:/data/db
- mongodb_test_config:/data/configdb
command: --wiredTigerCacheSizeGB 0.5 --quiet
healthcheck:
test: ["CMD", "mongosh", "--eval", "db.adminCommand('ping')"]
interval: 10s
timeout: 5s
retries: 5
start_period: 20s
restart: unless-stopped
networks:
- test-network
# PostgreSQL - Stellio Backend (PostGIS for geometry support)
postgres:
image: timescale/timescaledb-ha:pg15 # TimescaleDB with PostGIS included
container_name: test-postgres
ports:
- "5432:5432" # Map PostgreSQL port for external access
environment:
- POSTGRES_USER=stellio
- POSTGRES_PASSWORD=stellio_test
- POSTGRES_DB=stellio_test
volumes:
- postgres_test_data:/var/lib/postgresql/data
- ./scripts/database/init-stellio-dbs-timescale.sql:/docker-entrypoint-initdb.d/init-stellio-dbs.sql
healthcheck:
test: ["CMD-SHELL", "pg_isready -U stellio -d stellio_search"]
interval: 10s
timeout: 5s
retries: 10
start_period: 60s # Wait 60s before starting healthchecks (init script needs time)
restart: unless-stopped
networks:
- test-network
# Kafka - Event Streaming (for Stellio)
kafka:
image: apache/kafka:latest
container_name: test-kafka
user: root
ports:
- "9092:9092"
environment:
KAFKA_NODE_ID: 1
KAFKA_PROCESS_ROLES: broker,controller
KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:9092,CONTROLLER://0.0.0.0:9093
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092
KAFKA_CONTROLLER_LISTENER_NAMES: CONTROLLER
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT
KAFKA_CONTROLLER_QUORUM_VOTERS: 1@kafka:9093
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 1
KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 1
KAFKA_LOG_DIRS: /tmp/kraft-combined-logs
CLUSTER_ID: "MkU3OEVBNTcwNTJENDM2Qk"
volumes:
- kafka_test_data:/tmp/kraft-combined-logs
healthcheck:
test:
[
"CMD-SHELL",
"/opt/kafka/bin/kafka-broker-api-versions.sh --bootstrap-server localhost:9092 > /dev/null 2>&1 || exit 1",
]
interval: 15s
timeout: 15s
retries: 20
start_period: 90s # Kafka KRaft mode needs more time to fully initialize
restart: unless-stopped
networks:
- test-network
# ==========================================================================
# STELLIO CONTEXT BROKER
# ==========================================================================
# Stellio API Gateway
stellio-api-gateway:
image: stellio/stellio-api-gateway:2.26.1 # Use stable release instead of latest
container_name: test-stellio-api-gateway
ports:
- "8080:8080"
environment:
- SPRING_PROFILES_ACTIVE=docker
- SPRING_R2DBC_URL=r2dbc:postgresql://postgres:5432/stellio_search # Gateway needs search database!
- SPRING_R2DBC_USERNAME=stellio
- SPRING_R2DBC_PASSWORD=stellio_test
- SPRING_KAFKA_BOOTSTRAP_SERVERS=kafka:9092
- APPLICATION_AUTHENTICATION_ENABLED=false
depends_on:
postgres:
condition: service_healthy
kafka:
condition: service_healthy
search-service:
condition: service_started
subscription-service:
condition: service_started
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/actuator/health"]
interval: 15s
timeout: 10s
retries: 12
start_period: 60s # Spring Boot app needs time to start
restart: unless-stopped
networks:
- test-network
# Stellio Search Service (must be named 'search-service' for API Gateway routing)
search-service:
image: stellio/stellio-search-service:2.26.1 # Use stable release instead of latest
container_name: test-stellio-search
environment:
- SPRING_PROFILES_ACTIVE=docker
- SPRING_R2DBC_URL=r2dbc:postgresql://postgres:5432/stellio_search
- SPRING_R2DBC_USERNAME=stellio
- SPRING_R2DBC_PASSWORD=stellio_test
- SPRING_KAFKA_BOOTSTRAP_SERVERS=kafka:9092
# Flyway baseline mode to handle PostGIS pre-populated table
- SPRING_FLYWAY_BASELINE_ON_MIGRATE=true
- SPRING_FLYWAY_BASELINE_VERSION=0.0 # Baseline BEFORE V0_1 to run all migrations
- APPLICATION_AUTHENTICATION_ENABLED=false
# Neo4j Configuration - Enable Graph Database Support
- SPRING_NEO4J_URI=bolt://neo4j:7687
- SPRING_NEO4J_AUTHENTICATION_USERNAME=neo4j
- SPRING_NEO4J_AUTHENTICATION_PASSWORD=test12345
- APPLICATION_NEO4J_ENABLED=true
# Note: Gateway v2.26.1 routes to search-service:8083 (not entity-service:8082!)
ports:
- "8083:8083" # Official Stellio port for search-service
depends_on:
postgres:
condition: service_healthy
kafka:
condition: service_healthy
neo4j:
condition: service_healthy
networks:
test-network:
aliases:
- entity-service # Gateway hardcoded to look for this hostname
- search-service
restart: unless-stopped
# Stellio Subscription Service (must be named 'subscription-service' for API Gateway routing)
subscription-service:
image: stellio/stellio-subscription-service:2.26.1 # Use stable release instead of latest
container_name: test-stellio-subscription
environment:
- SPRING_PROFILES_ACTIVE=docker
- SPRING_R2DBC_URL=r2dbc:postgresql://postgres:5432/stellio_subscription
- SPRING_R2DBC_USERNAME=stellio
- SPRING_R2DBC_PASSWORD=stellio_test
- SPRING_KAFKA_BOOTSTRAP_SERVERS=kafka:9092
# Flyway baseline mode to handle PostGIS pre-populated table
- SPRING_FLYWAY_BASELINE_ON_MIGRATE=true
- SPRING_FLYWAY_BASELINE_VERSION=0.0 # Baseline BEFORE V0_1 to run all migrations
- APPLICATION_AUTHENTICATION_ENABLED=false
depends_on:
postgres:
condition: service_healthy
kafka:
condition: service_healthy
restart: unless-stopped
networks:
- test-network
# ==========================================================================
# PYTHON BACKEND (Citizen API + Orchestrator)
# ==========================================================================
python-backend:
build:
context: .
dockerfile: Dockerfile
container_name: python-backend
command: python main.py --run-orchestrator-now
restart: unless-stopped
ports:
- "8001:8001"
depends_on:
stellio-api-gateway:
condition: service_healthy
neo4j:
condition: service_healthy
fuseki:
condition: service_healthy
redis:
condition: service_healthy
mongodb:
condition: service_healthy
environment:
- PYTHONPATH=/app
- LOG_LEVEL=INFO
- STELLIO_URL=http://stellio-api-gateway:8080
- NEO4J_URI=bolt://neo4j:7687
- NEO4J_USER=neo4j
- NEO4J_PASSWORD=test12345
- FUSEKI_URL=http://fuseki:3030
- FUSEKI_DATASET=traffic-cameras
- REDIS_HOST=redis
- REDIS_PORT=6379
- REDIS_PASSWORD=test_redis_pass
- MONGODB_URI=mongodb://admin:mongodb_test_pass@mongodb:27017
volumes:
- ./config:/app/config
- ./data:/app/data
- ./logs:/app/logs
- ./assets:/app/assets
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8001/"]
interval: 15s
timeout: 10s
retries: 5
start_period: 30s
networks:
- test-network
# ==========================================================================
# CV VERIFICATION SERVICE (Background Service)
# ==========================================================================
cv-verification-service:
build:
context: .
dockerfile: Dockerfile
container_name: cv-verification-service
command: python start_cv_verification_service.py
restart: unless-stopped
depends_on:
stellio-api-gateway:
condition: service_healthy
environment:
- STELLIO_URL=http://stellio-api-gateway:8080
- LOG_LEVEL=INFO
- PYTHONPATH=/app
volumes:
- ./config:/app/config
- ./logs:/app/logs
- ./assets:/app/assets # YOLOX models
healthcheck:
test:
[
"CMD-SHELL",
'python -c "import os; exit(0 if os.path.exists(''/app/logs/cv_verification_service.log'') else 1)" || curl -sf http://stellio-api-gateway:8080/ngsi-ld/v1/entityTypes > /dev/null',
]
interval: 30s
timeout: 10s
retries: 5
start_period: 60s
networks:
- test-network
# ==========================================================================
# WEB APPLICATION - BACKEND & FRONTEND
# ==========================================================================
# Backend API Server (TypeScript/Express)
backend:
build:
context: ./apps/traffic-web-app/backend
dockerfile: Dockerfile
container_name: traffic-backend
ports:
- "3001:3001"
environment:
- NODE_ENV=production
- PORT=3001
- STELLIO_URL=http://stellio-api-gateway:8080
- NEO4J_URL=bolt://neo4j:7687
- NEO4J_URI=bolt://neo4j:7687
- NEO4J_USER=neo4j
- NEO4J_PASSWORD=test12345
- FUSEKI_URL=http://fuseki:3030
- FUSEKI_DATASET=traffic-cameras
- REDIS_HOST=redis
- REDIS_PORT=6379
- REDIS_PASSWORD=test_redis_pass
- MONGODB_URI=mongodb://admin:mongodb_test_pass@mongodb:27017
- POSTGRES_HOST=postgres
- POSTGRES_PORT=5432
- POSTGRES_USER=stellio
- POSTGRES_PASSWORD=stellio_test
- POSTGRES_DB=stellio_search
depends_on:
stellio-api-gateway:
condition: service_healthy
neo4j:
condition: service_healthy
fuseki:
condition: service_healthy
redis:
condition: service_healthy
mongodb:
condition: service_healthy
volumes:
- ./apps/traffic-web-app/backend/logs:/app/logs
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3001/health"]
interval: 10s
timeout: 5s
retries: 5
start_period: 20s
networks:
- test-network
restart: unless-stopped
# Frontend Web Application (React/Vite)
frontend:
build:
context: ./apps/traffic-web-app/frontend
dockerfile: Dockerfile
args:
- VITE_API_URL=http://localhost:3001
- VITE_WS_URL=ws://localhost:3001
container_name: traffic-frontend
ports:
- "3000:80"
depends_on:
backend:
condition: service_healthy
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:80"]
interval: 10s
timeout: 5s
retries: 3
networks:
- test-network
restart: unless-stopped
# ==========================================================================
# TEST RUNNER
# ==========================================================================
test-runner:
build:
context: .
dockerfile: docker/Dockerfile.test.optimized
args:
BUILDKIT_INLINE_CACHE: 1
container_name: test-runner
command: pytest tests/integration/test_complete_system.py -v --cov=agents --cov-report=html --cov-report=term-missing --cov-report=xml --tb=short
depends_on:
stellio-api-gateway:
condition: service_healthy
neo4j:
condition: service_healthy
fuseki:
condition: service_healthy
redis:
condition: service_healthy
environment:
# Service URLs
- STELLIO_URL=http://stellio-api-gateway:8080
- NEO4J_URL=bolt://neo4j:7687
- NEO4J_URI=bolt://neo4j:7687
- NEO4J_USER=neo4j
- NEO4J_PASSWORD=test12345
- FUSEKI_URL=http://fuseki:3030
- FUSEKI_DATASET=traffic-cameras
- REDIS_HOST=redis
- REDIS_PORT=6379
- REDIS_PASSWORD=test_redis_pass
# Test configuration
- TEST_DATA_DIR=/app/test_data
- TEST_OUTPUT_DIR=/app/test_output
- TEST_TIMEOUT=300
- COVERAGE_THRESHOLD=90
# Logging
- LOG_LEVEL=INFO
- PYTEST_VERBOSE=1
volumes:
- ./agents:/app/agents
- ./tests:/app/tests
- ./config:/app/config
- ./test_data:/app/test_data
- ./test_output:/app/test_output
- ./htmlcov:/app/htmlcov
- ./coverage.xml:/app/coverage.xml
networks:
- test-network
# ==========================================================================
# NETWORKS AND VOLUMES
# ==========================================================================
networks:
test-network:
driver: bridge
volumes:
neo4j_test_data:
driver: local
fuseki_test_data:
driver: local
redis_test_data:
driver: local
mongodb_test_data:
driver: local
mongodb_test_config:
driver: local
postgres_test_data:
driver: local
kafka_test_data:
driver: local