-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
283 lines (275 loc) · 8.47 KB
/
Copy pathdocker-compose.yml
File metadata and controls
283 lines (275 loc) · 8.47 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
services:
timescaledb:
image: timescale/timescaledb:latest-pg15
container_name: wardragon-timescaledb
environment:
POSTGRES_DB: wardragon
POSTGRES_USER: wardragon
POSTGRES_PASSWORD: ${DB_PASSWORD}
POSTGRES_INITDB_ARGS: "-E UTF8"
TIMESCALEDB_TELEMETRY: "off"
volumes:
- timescale-data:/var/lib/postgresql/data
- ./timescaledb:/docker-entrypoint-initdb.d:ro
ports:
- "127.0.0.1:5432:5432"
networks:
wardragon-net:
ipv4_address: 172.20.0.2
restart: unless-stopped
healthcheck:
test: ["CMD-SHELL", "pg_isready -U wardragon -d wardragon"]
interval: 10s
timeout: 5s
retries: 5
start_period: 30s
shm_size: 256MB
command:
- "postgres"
- "-c"
- "max_connections=200"
- "-c"
- "shared_buffers=256MB"
- "-c"
- "effective_cache_size=1GB"
- "-c"
- "work_mem=4MB"
- "-c"
- "maintenance_work_mem=64MB"
- "-c"
- "random_page_cost=1.1"
- "-c"
- "checkpoint_completion_target=0.9"
- "-c"
- "wal_buffers=16MB"
- "-c"
- "default_statistics_target=100"
- "-c"
- "log_min_duration_statement=1000"
collector:
build:
context: ./app
dockerfile: Dockerfile
target: collector
container_name: wardragon-collector
environment:
DATABASE_URL: postgresql://wardragon:${DB_PASSWORD}@timescaledb:5432/wardragon
KITS_CONFIG: /config/kits.yaml
LOG_LEVEL: ${LOG_LEVEL:-INFO}
POLL_INTERVAL_DRONES: ${POLL_INTERVAL_DRONES:-5}
POLL_INTERVAL_STATUS: ${POLL_INTERVAL_STATUS:-30}
MAX_RETRIES: ${MAX_RETRIES:-3}
RETRY_BACKOFF_FACTOR: ${RETRY_BACKOFF_FACTOR:-2}
volumes:
- ./config:/config:ro
- ./logs/collector:/app/logs
depends_on:
timescaledb:
condition: service_healthy
networks:
- wardragon-net
restart: unless-stopped
# Use Docker's internal DNS only - prevents hanging when no internet
dns:
- 127.0.0.11
extra_hosts:
- "timescaledb:172.20.0.2"
- "host.docker.internal:host-gateway"
healthcheck:
test: ["CMD-SHELL", "python -c 'import os; exit(0 if os.path.exists(\"/tmp/collector_healthy\") else 1)' || exit 1"]
interval: 30s
timeout: 10s
retries: 3
start_period: 60s
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
web:
build:
context: ./app
dockerfile: Dockerfile
target: web
container_name: wardragon-web
environment:
DATABASE_URL: postgresql://wardragon:${DB_PASSWORD}@timescaledb:5432/wardragon
LOG_LEVEL: ${LOG_LEVEL:-INFO}
API_TITLE: "WarDragon Analytics API"
API_VERSION: "1.0.0"
CORS_ORIGINS: ${CORS_ORIGINS:-*}
MAX_QUERY_RANGE_HOURS: ${MAX_QUERY_RANGE_HOURS:-168}
ports:
- "${WEB_PORT:-8090}:8090"
depends_on:
timescaledb:
condition: service_healthy
networks:
- wardragon-net
restart: unless-stopped
# Use Docker's internal DNS only - prevents hanging when no internet
dns:
- 127.0.0.11
extra_hosts:
- "timescaledb:172.20.0.2"
- "host.docker.internal:host-gateway"
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:8090/health || exit 1"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
grafana:
image: grafana/grafana:10.4.1
container_name: wardragon-grafana
user: "472:0"
environment:
GF_SECURITY_ADMIN_USER: ${GRAFANA_USER:-admin}
GF_SECURITY_ADMIN_PASSWORD: ${GRAFANA_PASSWORD}
GF_SECURITY_SECRET_KEY: ${GRAFANA_SECRET_KEY}
GF_SERVER_ROOT_URL: ${GRAFANA_ROOT_URL:-http://localhost:3000}
GF_ANALYTICS_REPORTING_ENABLED: "false"
GF_ANALYTICS_CHECK_FOR_UPDATES: "false"
GF_PLUGINS_CHECK_FOR_UPDATES: "false"
GF_USERS_ALLOW_SIGN_UP: "false"
GF_LOG_LEVEL: ${GRAFANA_LOG_LEVEL:-info}
GF_AUTH_ANONYMOUS_ENABLED: "false"
GF_SECURITY_DISABLE_GRAVATAR: "true"
GF_SECURITY_COOKIE_SECURE: "${GRAFANA_COOKIE_SECURE:-false}"
GF_SECURITY_COOKIE_SAMESITE: "strict"
# Disable ALL external connectivity attempts for offline operation
GF_ANALYTICS_FEEDBACK_LINKS_ENABLED: "false"
GF_NEWS_NEWS_FEED_ENABLED: "false"
GF_LIVE_ALLOWED_ORIGINS: ""
GF_ENTERPRISE_LICENSE_VALIDATION_TYPE: "offline"
GF_SNAPSHOTS_EXTERNAL_ENABLED: "false"
GF_RENDERING_SERVER_URL: ""
GF_RENDERING_CALLBACK_URL: ""
GF_UNIFIED_ALERTING_SCREENSHOTS_CAPTURE: "false"
DB_PASSWORD: ${DB_PASSWORD}
# Use Docker's internal DNS only - prevents hanging when no internet
dns:
- 127.0.0.11
extra_hosts:
- "timescaledb:172.20.0.2"
volumes:
- grafana-data:/var/lib/grafana
- ./grafana/dashboards:/etc/grafana/provisioning/dashboards:ro
- ./grafana/datasources:/etc/grafana/provisioning/datasources:ro
- ./grafana/dashboards-json:/var/lib/grafana/dashboards:ro
ports:
- "${GRAFANA_PORT:-3000}:3000"
depends_on:
timescaledb:
condition: service_healthy
networks:
- wardragon-net
restart: unless-stopped
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:3000/api/health || exit 1"]
interval: 30s
timeout: 10s
retries: 3
start_period: 60s
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
# =============================================================================
# MQTT Services (Enabled by default)
# =============================================================================
# These services enable push-based data ingest from WarDragon kits via MQTT.
# Alternative to HTTP polling - kits send data directly to the Analytics stack.
#
# Configuration:
# 1. Configure DragonSync on kits to publish to this server's IP:1883
# 2. See docs/mqtt-ingest.md for security hardening options
#
# To disable MQTT (use HTTP polling only):
# Run: docker compose up -d --scale mosquitto=0 --scale mqtt-ingest=0
mosquitto:
image: eclipse-mosquitto:2
container_name: wardragon-mosquitto
volumes:
- ./mosquitto/mosquitto.conf:/mosquitto/config/mosquitto.conf:ro
- ./mosquitto/certs:/mosquitto/certs:ro
- mosquitto-data:/mosquitto/data
- mosquitto-log:/mosquitto/log
ports:
- "${MQTT_BROKER_PORT:-1883}:1883"
- "${MQTT_TLS_PORT:-8883}:8883"
networks:
wardragon-net:
ipv4_address: 172.20.0.10
restart: unless-stopped
healthcheck:
test: ["CMD", "mosquitto_sub", "-t", "$$SYS/#", "-C", "1", "-i", "healthcheck", "-W", "3"]
interval: 30s
timeout: 10s
retries: 3
start_period: 10s
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
mqtt-ingest:
build:
context: ./app
dockerfile: Dockerfile
target: mqtt-ingest
container_name: wardragon-mqtt-ingest
environment:
DATABASE_URL: postgresql://wardragon:${DB_PASSWORD}@timescaledb:5432/wardragon
MQTT_BROKER_HOST: mosquitto
MQTT_BROKER_PORT: 1883
MQTT_USERNAME: ${MQTT_USERNAME:-}
MQTT_PASSWORD: ${MQTT_PASSWORD:-}
MQTT_USE_TLS: ${MQTT_TLS_ENABLED:-false}
MQTT_TOPIC_DRONES: ${MQTT_TOPIC_DRONES:-wardragon/drones}
MQTT_TOPIC_DRONE_PREFIX: ${MQTT_TOPIC_DRONE_PREFIX:-wardragon/drone/}
MQTT_TOPIC_AIRCRAFT: ${MQTT_TOPIC_AIRCRAFT:-wardragon/aircraft}
MQTT_TOPIC_SIGNALS: ${MQTT_TOPIC_SIGNALS:-wardragon/signals}
MQTT_TOPIC_SYSTEM: ${MQTT_TOPIC_SYSTEM:-wardragon/system}
LOG_LEVEL: ${LOG_LEVEL:-INFO}
depends_on:
timescaledb:
condition: service_healthy
mosquitto:
condition: service_healthy
networks:
- wardragon-net
restart: unless-stopped
dns:
- 127.0.0.11
extra_hosts:
- "timescaledb:172.20.0.2"
- "mosquitto:172.20.0.10"
healthcheck:
test: ["CMD-SHELL", "python -c 'import os; exit(0 if os.path.exists(\"/tmp/mqtt_ingest_healthy\") else 1)' || exit 1"]
interval: 30s
timeout: 10s
retries: 3
start_period: 30s
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
networks:
wardragon-net:
driver: bridge
ipam:
config:
- subnet: 172.20.0.0/16
volumes:
timescale-data:
grafana-data:
mosquitto-data:
mosquitto-log: