-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
442 lines (421 loc) · 16.9 KB
/
docker-compose.yml
File metadata and controls
442 lines (421 loc) · 16.9 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
#================================================================================================
# TelemetryFlow Core - Docker Compose Configuration
# IAM Module Only (PostgreSQL + Backend)
#
# PROFILES:
# - core: Essential services (postgres, clickhouse, backend) - No monitoring
# - monitoring: Observability stack (otel-collector, jaeger, prometheus, grafana)
# - tools: Management tools (portainer)
# - all: All services combined
#
# USAGE:
# docker-compose --profile core up -d # Core services only
# docker-compose --profile core --profile monitoring up -d # Core + monitoring
# docker-compose --profile all up -d # All services
#================================================================================================
#================================================================================================
# NETWORK SETUP
#================================================================================================
networks:
telemetryflow_core_net:
name: telemetryflow_core_net
driver: bridge
ipam:
config:
- subnet: 172.151.0.0/16
#================================================================================================
# VOLUME SETUP
#================================================================================================
volumes:
vol_postgres_data:
driver: local
driver_opts:
type: none
o: bind
device: /opt/data/docker/telemetryflow-core/postgres
vol_clickhouse_data:
driver: local
driver_opts:
type: none
o: bind
device: /opt/data/docker/telemetryflow-core/clickhouse/data
vol_clickhouse_logs:
driver: local
driver_opts:
type: none
o: bind
device: /opt/data/docker/telemetryflow-core/clickhouse/logs
vol_prometheus_data:
driver: local
driver_opts:
type: none
o: bind
device: /opt/data/docker/telemetryflow-core/prometheus
vol_grafana_data:
vol_portainer:
driver: local
driver_opts:
type: none
o: bind
device: /opt/data/docker/telemetryflow-core/portainer
#================================================================================================
# SERVICES
#================================================================================================
services:
#----------------------------------------------------------------------------------------------
# POSTGRESQL - IAM Data Storage
#----------------------------------------------------------------------------------------------
postgres:
profiles: ["core", "all"]
platform: linux/amd64
image: postgres:${POSTGRES_VERSION:-16-alpine}
container_name: ${CONTAINER_POSTGRES:-telemetryflow_core_postgres}
restart: unless-stopped
ports:
- "${PORT_POSTGRES:-5432}:5432"
environment:
- TZ=${TZ:-UTC}
- POSTGRES_USER=${POSTGRES_USERNAME:-postgres}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-telemetryflow123}
- POSTGRES_DB=${POSTGRES_DB:-telemetryflow_db}
- PGDATA=/var/lib/postgresql/data/pgdata
volumes:
- vol_postgres_data:/var/lib/postgresql/data
- ./config/postgresql/postgresql.conf:/etc/postgresql/postgresql.conf:ro
networks:
telemetryflow_core_net:
ipv4_address: ${CONTAINER_IP_POSTGRES:-172.151.151.20}
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USERNAME:-postgres} -d ${POSTGRES_DB:-telemetryflow_core}"]
interval: 10s
timeout: 5s
retries: 5
start_period: 10s
#----------------------------------------------------------------------------------------------
# BACKEND - NestJS API (Core Profile - No OTEL dependency)
#----------------------------------------------------------------------------------------------
backend:
profiles: ["core"]
platform: linux/amd64
build:
context: .
dockerfile: Dockerfile
container_name: ${CONTAINER_BACKEND:-telemetryflow_core_backend}
restart: unless-stopped
ports:
- "${PORT:-3000}:3000"
environment:
- NODE_ENV=${NODE_ENV:-production}
- PORT=3000
- TZ=${TZ:-UTC}
# PostgreSQL
- POSTGRES_HOST=postgres
- POSTGRES_PORT=5432
- POSTGRES_DB=${POSTGRES_DB:-telemetryflow_db}
- POSTGRES_USERNAME=${POSTGRES_USERNAME:-postgres}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-telemetryflow123}
# ClickHouse
- CLICKHOUSE_HOST=clickhouse
- CLICKHOUSE_PORT=8123
- CLICKHOUSE_DB=${CLICKHOUSE_DB:-telemetryflow_db}
- CLICKHOUSE_USER=${CLICKHOUSE_USER:-default}
- CLICKHOUSE_PASSWORD=${CLICKHOUSE_PASSWORD:-telemetryflow123}
# JWT
- JWT_SECRET=${JWT_SECRET}
- JWT_EXPIRES_IN=${JWT_EXPIRES_IN:-24h}
- SESSION_SECRET=${SESSION_SECRET}
# Logging
- LOGGER_TYPE=${LOGGER_TYPE:-winston}
- LOG_LEVEL=${LOG_LEVEL:-info}
- LOG_PRETTY_PRINT=${LOG_PRETTY_PRINT:-false}
- LOG_FILE_ENABLED=${LOG_FILE_ENABLED:-true}
- LOG_FILE_DIRNAME=logs
- LOG_FILE_FILENAME=app-%DATE%.log
# OpenTelemetry (disabled for core profile)
- OTEL_ENABLED=false
- OTEL_SERVICE_NAME=${OTEL_SERVICE_NAME:-telemetryflow-core}
volumes:
- ./logs:/app/logs
depends_on:
postgres:
condition: service_healthy
clickhouse:
condition: service_healthy
networks:
telemetryflow_core_net:
ipv4_address: ${CONTAINER_IP_BACKEND:-172.151.151.10}
healthcheck:
test: ["CMD-SHELL", "wget --no-verbose --tries=1 --spider http://localhost:3000/health || exit 1"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
#----------------------------------------------------------------------------------------------
# BACKEND - NestJS API (All Profile - With OTEL dependency)
#----------------------------------------------------------------------------------------------
backend-with-monitoring:
profiles: ["all"]
platform: linux/amd64
build:
context: .
dockerfile: Dockerfile
container_name: ${CONTAINER_BACKEND:-telemetryflow_core_backend}
restart: unless-stopped
ports:
- "${PORT:-3000}:3000"
environment:
- NODE_ENV=${NODE_ENV:-production}
- PORT=3000
- TZ=${TZ:-UTC}
# PostgreSQL
- POSTGRES_HOST=postgres
- POSTGRES_PORT=5432
- POSTGRES_DB=${POSTGRES_DB:-telemetryflow_db}
- POSTGRES_USERNAME=${POSTGRES_USERNAME:-postgres}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-telemetryflow123}
# ClickHouse
- CLICKHOUSE_HOST=clickhouse
- CLICKHOUSE_PORT=8123
- CLICKHOUSE_DB=${CLICKHOUSE_DB:-telemetryflow_db}
- CLICKHOUSE_USER=${CLICKHOUSE_USER:-default}
- CLICKHOUSE_PASSWORD=${CLICKHOUSE_PASSWORD:-telemetryflow123}
# JWT
- JWT_SECRET=${JWT_SECRET}
- JWT_EXPIRES_IN=${JWT_EXPIRES_IN:-24h}
- SESSION_SECRET=${SESSION_SECRET}
# Logging
- LOGGER_TYPE=${LOGGER_TYPE:-winston}
- LOG_LEVEL=${LOG_LEVEL:-info}
- LOG_PRETTY_PRINT=${LOG_PRETTY_PRINT:-false}
- LOG_FILE_ENABLED=${LOG_FILE_ENABLED:-true}
- LOG_FILE_DIRNAME=logs
- LOG_FILE_FILENAME=app-%DATE%.log
# OpenTelemetry (enabled for all profile)
- OTEL_ENABLED=${OTEL_ENABLED:-true}
- OTEL_SERVICE_NAME=${OTEL_SERVICE_NAME:-telemetryflow-core}
- OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector:4318
volumes:
- ./logs:/app/logs
depends_on:
postgres:
condition: service_healthy
clickhouse:
condition: service_healthy
otel-collector:
condition: service_started
networks:
telemetryflow_core_net:
ipv4_address: ${CONTAINER_IP_BACKEND:-172.151.151.10}
healthcheck:
test: ["CMD-SHELL", "wget --no-verbose --tries=1 --spider http://localhost:3000/health || exit 1"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
#----------------------------------------------------------------------------------------------
# CLICKHOUSE - Audit Log Storage
#----------------------------------------------------------------------------------------------
clickhouse:
profiles: ["core", "all"]
platform: linux/amd64
image: clickhouse/clickhouse-server:${CLICKHOUSE_VERSION:-latest}
container_name: ${CONTAINER_CLICKHOUSE:-telemetryflow_core_clickhouse}
restart: unless-stopped
ports:
- "${PORT_CLICKHOUSE_HTTP:-8123}:8123" # HTTP
- "${PORT_CLICKHOUSE_NATIVE:-9000}:9000" # Native
- "${PORT_CLICKHOUSE_METRICS:-9363}:9363" # Prometheus metrics
environment:
- TZ=${TZ:-UTC}
- CLICKHOUSE_DB=${CLICKHOUSE_DB:-telemetryflow_db}
- CLICKHOUSE_USER=${CLICKHOUSE_USER:-default}
- CLICKHOUSE_PASSWORD=${CLICKHOUSE_PASSWORD:-telemetryflow123}
volumes:
- vol_clickhouse_data:/var/lib/clickhouse
- vol_clickhouse_logs:/var/log/clickhouse-server
# - ./config/clickhouse/config.d:/etc/clickhouse-server/config.d
networks:
telemetryflow_core_net:
ipv4_address: ${CONTAINER_IP_CLICKHOUSE:-172.151.151.40}
healthcheck:
test: ["CMD", "wget", "--spider", "-q", "http://localhost:8123/ping"]
interval: 10s
timeout: 5s
retries: 5
start_period: 10s
#----------------------------------------------------------------------------------------------
# OTEL COLLECTOR - OpenTelemetry Collector
#----------------------------------------------------------------------------------------------
# Supports dual ingestion: v1 (OTEL standard) and v2 (TelemetryFlow enhanced)
#
# OTLP HTTP Endpoints:
# TelemetryFlow Platform (Recommended - TFO Standalone):
# POST http://localhost:4318/v2/traces
# POST http://localhost:4318/v2/metrics
# POST http://localhost:4318/v2/logs
#
# OTEL Community (Backwards Compatible - OCB/Standard):
# POST http://localhost:4318/v1/traces
# POST http://localhost:4318/v1/metrics
# POST http://localhost:4318/v1/logs
#
# gRPC (Both versions via same port): localhost:4317
#----------------------------------------------------------------------------------------------
otel-collector:
profiles: ["monitoring", "all"]
platform: linux/amd64
# =============================================================================
# TelemetryFlow Collector (TFO-Collector) - TFO format with OTLP support (v1.1.2+)
image: telemetryflow/telemetryflow-collector:${TFO_VERSION:-latest}
command: ["--config=/etc/tfo-collector/tfo-collector.yaml"]
# =============================================================================
# TelemetryFlow Collector OCB (TFO-Collector-OCB) - Standard OTEL format
# image: telemetryflow/telemetryflow-collector:${TFO_VERSION:-latest}
# command: ["--config=/etc/tfo-collector/otel-collector.yaml"]
# =============================================================================
# OTEL Collector Community Contributor (Standard OTEL format)
# image: otel/opentelemetry-collector-contrib:${OTEL_VERSION:-0.142.0}
# command: ["--config=/etc/otelcol-contrib/config.yaml"]
# =============================================================================
container_name: ${CONTAINER_OTEL:-telemetryflow_core_otel}
restart: unless-stopped
volumes:
# TelemetryFlow Collector config (Custom TFO format)
- ./config/otel/tfo-collector.yaml:/etc/tfo-collector/tfo-collector.yaml:ro
# =============================================================================
# TelemetryFlow Collector OCB config (Standard OTEL format)
# - ./config/otel/otel-collector.yaml:/etc/tfo-collector/otel-collector.yaml:ro
# =============================================================================
# OTEL Collector Community Contributor config (Standard OTEL format)
# - ./config/otel/otel-collector.yaml:/etc/otelcol-contrib/config.yaml:ro
ports:
- "${PORT_OTEL_GRPC:-4317}:4317" # OTLP gRPC (v1 & v2)
- "${PORT_OTEL_HTTP:-4318}:4318" # OTLP HTTP (v1 & v2)
- "${PORT_OTEL_METRICS:-8889}:8889" # Prometheus metrics
- "${PORT_OTEL_HEALTH:-13133}:13133" # Health check
- "${PORT_OTEL_ZPAGES:-55679}:55679" # zPages
- "${PORT_OTEL_PPROF:-1777}:1777" # pprof
healthcheck:
test: ["CMD", "wget", "--spider", "-q", "http://localhost:13133"]
interval: 10s
timeout: 5s
retries: 5
start_period: 10s
networks:
telemetryflow_core_net:
ipv4_address: ${CONTAINER_IP_OTEL:-172.151.151.30}
#----------------------------------------------------------------------------------------------
# JAEGER V2 - Distributed Tracing UI (OpenTelemetry-based)
#----------------------------------------------------------------------------------------------
jaeger:
profiles: ["monitoring", "all"]
platform: linux/amd64
image: jaegertracing/jaeger:${JAEGER_VERSION:-2.13.0}
container_name: ${CONTAINER_JAEGER:-telemetryflow_core_jaeger}
restart: unless-stopped
ports:
- "${PORT_JAEGER_UI:-16686}:16686" # Jaeger UI
environment:
- SPAN_STORAGE_TYPE=memory
- METRICS_STORAGE_TYPE=prometheus
- PROMETHEUS_SERVER_URL=http://prometheus:9090
- PROMETHEUS_QUERY_SUPPORT_SPANMETRICS_CONNECTOR=true
- PROMETHEUS_QUERY_NAMESPACE=telemetryflow_core
- PROMETHEUS_QUERY_DURATION_UNIT=ms
- PROMETHEUS_QUERY_NORMALIZE_CALLS=true
- PROMETHEUS_QUERY_NORMALIZE_DURATION=true
networks:
telemetryflow_core_net:
ipv4_address: ${CONTAINER_IP_JAEGER:-172.151.151.60}
healthcheck:
test: ["CMD", "wget", "--spider", "-q", "http://localhost:16686"]
interval: 10s
timeout: 5s
retries: 5
start_period: 10s
depends_on:
- prometheus
#----------------------------------------------------------------------------------------------
# PROMETHEUS - Metrics Collection
#----------------------------------------------------------------------------------------------
prometheus:
profiles: ["monitoring", "all"]
platform: linux/amd64
image: prom/prometheus:${PROMETHEUS_VERSION:-latest}
container_name: ${CONTAINER_PROMETHEUS:-telemetryflow_core_prometheus}
restart: unless-stopped
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:
- "${PORT_PROMETHEUS:-9090}:9090"
volumes:
- ./config/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro
- vol_prometheus_data:/prometheus
networks:
telemetryflow_core_net:
ipv4_address: ${CONTAINER_IP_PROMETHEUS:-172.151.151.50}
depends_on:
- otel-collector
healthcheck:
test: ["CMD", "wget", "--spider", "-q", "http://localhost:9090/-/healthy"]
interval: 10s
timeout: 5s
retries: 5
start_period: 10s
#----------------------------------------------------------------------------------------------
# GRAFANA - Metrics Visualization & SPM Dashboards
#----------------------------------------------------------------------------------------------
grafana:
profiles: ["monitoring", "all"]
platform: linux/amd64
image: grafana/grafana:${GRAFANA_VERSION:-latest}
container_name: ${CONTAINER_GRAFANA:-telemetryflow_core_grafana}
restart: unless-stopped
ports:
- "${PORT_GRAFANA:-3001}:3000"
environment:
- GF_SECURITY_ADMIN_USER=${GF_SECURITY_ADMIN_USER:-admin}
- GF_SECURITY_ADMIN_PASSWORD=${GF_SECURITY_ADMIN_PASSWORD:-admin}
volumes:
- vol_grafana_data:/var/lib/grafana
- ./config/grafana/provisioning:/etc/grafana/provisioning:ro
- ./config/grafana/dashboards:/var/lib/grafana/dashboards:ro
networks:
telemetryflow_core_net:
ipv4_address: ${CONTAINER_IP_GRAFANA:-172.151.151.70}
healthcheck:
test: ["CMD", "wget", "--spider", "-q", "http://localhost:3000/api/health"]
interval: 10s
timeout: 5s
retries: 5
start_period: 10s
depends_on:
- prometheus
#----------------------------------------------------------------------------------------------
# PORTAINER - Docker Container Management UI
#----------------------------------------------------------------------------------------------
portainer:
profiles: ["tools", "all"]
platform: linux/amd64
image: portainer/portainer-ce:${PORTAINER_VERSION:-latest}
container_name: ${CONTAINER_PORTAINER:-telemetryflow_core_portainer}
restart: unless-stopped
ports:
- "${PORT_PORTAINER:-9100}:9000"
- "${PORT_PORTAINER_HTTPS:-9443}:9443"
environment:
- TZ=${TZ:-UTC}
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- vol_portainer:/data
networks:
telemetryflow_core_net:
ipv4_address: ${CONTAINER_IP_PORTAINER:-172.151.151.5}
healthcheck:
test: ["CMD", "wget", "--spider", "-q", "http://localhost:9000/api/status"]
interval: 30s
timeout: 5s
retries: 3