-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.dev.yaml
More file actions
362 lines (342 loc) · 10.9 KB
/
docker-compose.dev.yaml
File metadata and controls
362 lines (342 loc) · 10.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
services:
# ============================================
# Infrastructure Services
# ============================================
mongo:
image: mongo:7.0
container_name: mongo
command: [ "--replSet", "rs0", "--bind_ip_all", "--port", "27017" ]
ports:
- 27017:27017
extra_hosts:
- "host.docker.internal:host-gateway"
healthcheck:
test: echo "try { rs.status() } catch (err) { rs.initiate({_id:'rs0',members:[{_id:0,host:'host.docker.internal:27017'}]}) }" | mongosh --port 27017 --quiet
interval: 5s
timeout: 30s
start_period: 0s
start_interval: 1s
retries: 30
volumes:
- "mongo_data:/data/db"
- "mongo_config:/data/configdb"
networks:
- ns-network
kafka:
image: apache/kafka-native
container_name: kafka
ports:
- "9092:9092"
environment:
# Configure listeners for both docker and host communication
KAFKA_LISTENERS: CONTROLLER://localhost:9091,HOST://0.0.0.0:9092,DOCKER://0.0.0.0:9093
KAFKA_ADVERTISED_LISTENERS: HOST://localhost:9092,DOCKER://kafka:9093
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: CONTROLLER:PLAINTEXT,DOCKER:PLAINTEXT,HOST:PLAINTEXT
# Settings required for KRaft mode
KAFKA_NODE_ID: 1
KAFKA_PROCESS_ROLES: broker,controller
KAFKA_CONTROLLER_LISTENER_NAMES: CONTROLLER
KAFKA_CONTROLLER_QUORUM_VOTERS: 1@localhost:9091
# Listener to use for broker-to-broker communication
KAFKA_INTER_BROKER_LISTENER_NAME: DOCKER
# Required for a single node cluster
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
# Disable auto-topic creation - API server will create topics with correct partitions
KAFKA_AUTO_CREATE_TOPICS_ENABLE: "false"
volumes:
- "kafka_data:/var/lib/kafka/data"
networks:
- ns-network
kafka-ui:
image: kafbat/kafka-ui:main
container_name: kafka-ui
ports:
- 8080:8080
environment:
DYNAMIC_CONFIG_ENABLED: "true"
KAFKA_CLUSTERS_0_NAME: local
KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS: kafka:9093
depends_on:
- kafka
networks:
- ns-network
redis:
image: redis:7-alpine
container_name: redis
ports:
- "6379:6379"
command: redis-server --appendonly yes
volumes:
- "redis_data:/data"
networks:
- ns-network
healthcheck:
test: [ "CMD", "redis-cli", "ping" ]
interval: 5s
timeout: 3s
retries: 5
# ============================================
# Observability Services
# ============================================
loki:
image: grafana/loki:2.9.0
container_name: loki
ports:
- "3100:3100"
command: -config.file=/etc/loki/local-config.yaml
volumes:
- "loki_data:/loki"
networks:
- ns-network
healthcheck:
test: [ "CMD-SHELL", "wget --no-verbose --tries=1 --spider http://localhost:3100/ready || exit 1" ]
interval: 10s
timeout: 5s
retries: 5
grafana:
image: grafana/grafana:10.2.0
container_name: grafana
ports:
- "3001:3000"
environment:
- GF_PATHS_PROVISIONING=/etc/grafana/provisioning
- GF_AUTH_ANONYMOUS_ENABLED=true
- GF_AUTH_ANONYMOUS_ORG_ROLE=Admin
- GF_SECURITY_ADMIN_PASSWORD=admin
volumes:
- "grafana_data:/var/lib/grafana"
depends_on:
loki:
condition: service_healthy
networks:
- ns-network
# ============================================
# Application Services
# ============================================
# API Server - Handles HTTP requests for /notification and /notification/batch
api:
build:
context: .
dockerfile: Dockerfile
container_name: api
image: simplens-core:latest
ports:
- "3000:3000"
env_file:
- .env
environment:
NODE_ENV: ${NODE_ENV:-production}
PORT: ${PORT:-3000}
MONGO_URI: mongodb://mongo:27017/notification_service?replicaSet=rs0
REDIS_URL: redis://redis:6379
BROKERS: kafka:9093
NS_API_KEY: ${NS_API_KEY:-dev-api-key-change-in-production}
MAX_BATCH_REQ_LIMIT: ${MAX_BATCH_REQ_LIMIT:-1000}
LOKI_URL: http://loki:3100
LOG_LEVEL: ${LOG_LEVEL:-info}
DELAYED_PARTITION: ${DELAYED_PARTITION:-1}
NOTIFICATION_STATUS_PARTITION: ${NOTIFICATION_STATUS_PARTITION:-1}
SIMPLENS_CONFIG_PATH: ${SIMPLENS_CONFIG_PATH:-/app/simplens.config.yaml}
volumes:
# Mount plugins directory for user-installed plugins (optional)
- plugin-data:/app/.plugins
- ./simplens.config.yaml:/app/simplens.config.yaml:ro
command: [ "node", "dist/api/server.js" ]
depends_on:
mongo:
condition: service_healthy
kafka:
condition: service_started
redis:
condition: service_healthy
loki:
condition: service_healthy
networks:
- ns-network
restart: unless-stopped
healthcheck:
test: [ "CMD", "node", "-e", "require('http').get('http://localhost:3000/health', (r) => process.exit(r.statusCode === 200 ? 0 : 1)).on('error', () => process.exit(1))" ]
interval: 30s
timeout: 10s
retries: 3
start_period: 10s
# Background Worker - Polls outbox, publishes to Kafka, updates status in MongoDB
worker:
image: simplens-core:latest
extra_hosts:
- "host.docker.internal:host-gateway"
env_file:
- .env
environment:
NODE_ENV: ${NODE_ENV:-production}
MONGO_URI: mongodb://mongo:27017/notification_service?replicaSet=rs0
REDIS_URL: redis://redis:6379
BROKERS: kafka:9093
OUTBOX_POLL_INTERVAL_MS: ${OUTBOX_POLL_INTERVAL_MS:-5000}
OUTBOX_BATCH_SIZE: ${OUTBOX_BATCH_SIZE:-100}
OUTBOX_CLAIM_TIMEOUT_MS: ${OUTBOX_CLAIM_TIMEOUT_MS:-30000}
LOKI_URL: http://loki:3100
LOG_LEVEL: ${LOG_LEVEL:-info}
command: [ "node", "dist/workers/worker.js" ]
depends_on:
mongo:
condition: service_healthy
kafka:
condition: service_started
redis:
condition: service_healthy
loki:
condition: service_healthy
api:
condition: service_healthy
networks:
- ns-network
restart: unless-stopped
# Unified Notification Processor - Uses plugin system for all channels
notification-processor:
image: simplens-core:latest
env_file:
- .env
environment:
NODE_ENV: ${NODE_ENV:-production}
MONGO_URI: mongodb://mongo:27017/notification_service?replicaSet=rs0
REDIS_URL: redis://redis:6379
BROKERS: kafka:9093
# Plugin Configuration - path to simplens.config.yaml
SIMPLENS_CONFIG_PATH: ${SIMPLENS_CONFIG_PATH:-/app/simplens.config.yaml}
# Processor Mode - 'all' for all channels, or specific channel name
PROCESSOR_CHANNEL: ${PROCESSOR_CHANNEL:-all}
# Retry Configuration
MAX_RETRY_COUNT: ${MAX_RETRY_COUNT:-5}
IDEMPOTENCY_TTL_SECONDS: ${IDEMPOTENCY_TTL_SECONDS:-86400}
PROCESSING_TTL_SECONDS: ${PROCESSING_TTL_SECONDS:-120}
# Logging
LOKI_URL: http://loki:3100
LOG_LEVEL: ${LOG_LEVEL:-info}
command: [ "node", "dist/processors/unified/unified.processor.js" ]
volumes:
# Mount plugins directory for user-installed plugins (optional)
- plugin-data:/app/.plugins
- ./simplens.config.yaml:/app/simplens.config.yaml:ro
depends_on:
mongo:
condition: service_healthy
kafka:
condition: service_started
redis:
condition: service_healthy
loki:
condition: service_healthy
api:
condition: service_healthy
networks:
- ns-network
restart: unless-stopped
# Delayed Processor - Handles scheduled notifications via Redis ZSET queue
delayed-processor:
image: simplens-core:latest
env_file:
- .env
environment:
NODE_ENV: ${NODE_ENV:-production}
MONGO_URI: mongodb://mongo:27017/notification_service?replicaSet=rs0
REDIS_URL: redis://redis:6379
BROKERS: kafka:9093
# Delayed Queue Configuration
DELAYED_POLL_INTERVAL_MS: ${DELAYED_POLL_INTERVAL_MS:-1000}
DELAYED_BATCH_SIZE: ${DELAYED_BATCH_SIZE:-10}
MAX_POLLER_RETRIES: ${MAX_POLLER_RETRIES:-3}
# Logging
LOKI_URL: http://loki:3100
LOG_LEVEL: ${LOG_LEVEL:-info}
command: [ "node", "dist/processors/delayed/delayed.processor.js" ]
depends_on:
mongo:
condition: service_healthy
kafka:
condition: service_started
redis:
condition: service_healthy
loki:
condition: service_healthy
api:
condition: service_healthy
networks:
- ns-network
restart: unless-stopped
# Recovery Service - Detects stuck notifications and creates alerts
recovery:
image: simplens-core:latest
env_file:
- .env
environment:
NODE_ENV: ${NODE_ENV:-production}
MONGO_URI: mongodb://mongo:27017/notification_service?replicaSet=rs0
REDIS_URL: redis://redis:6379
# Recovery Configuration
RECOVERY_POLL_INTERVAL_MS: ${RECOVERY_POLL_INTERVAL_MS:-60000}
PROCESSING_STUCK_THRESHOLD_MS: ${PROCESSING_STUCK_THRESHOLD_MS:-300000}
PENDING_STUCK_THRESHOLD_MS: ${PENDING_STUCK_THRESHOLD_MS:-300000}
RECOVERY_BATCH_SIZE: ${RECOVERY_BATCH_SIZE:-50}
MAX_RETRY_COUNT: ${MAX_RETRY_COUNT:-5}
# Cleanup Configuration
CLEANUP_RESOLVED_ALERTS_RETENTION_MS: ${CLEANUP_RESOLVED_ALERTS_RETENTION_MS:-86400000}
CLEANUP_PROCESSED_STATUS_OUTBOX_RETENTION_MS: ${CLEANUP_PROCESSED_STATUS_OUTBOX_RETENTION_MS:-86400000}
# Logging
LOKI_URL: http://loki:3100
LOG_LEVEL: ${LOG_LEVEL:-info}
command: [ "node", "dist/workers/recovery/recovery.service.js" ]
depends_on:
mongo:
condition: service_healthy
redis:
condition: service_healthy
loki:
condition: service_healthy
api:
condition: service_healthy
networks:
- ns-network
restart: unless-stopped
# Admin Dashboard - Next.js web app for monitoring notifications
dashboard:
build:
context: ./dashboard
dockerfile: Dockerfile
container_name: dashboard
ports:
- "3002:3002"
env_file:
- .env
environment:
NODE_ENV: production
PORT: ${DASHBOARD_PORT:-3002}
MONGO_URI: mongodb://mongo:27017/notification_service?replicaSet=rs0
AUTH_SECRET: ${AUTH_SECRET:-change-this-in-production}
ADMIN_USERNAME: ${ADMIN_USERNAME:-admin}
ADMIN_PASSWORD: ${ADMIN_PASSWORD:-admin}
AUTH_TRUST_HOST: ${AUTH_TRUST_HOST:-true}
# For sending notifications
API_BASE_URL: http://api:${PORT:-3000}
NS_API_KEY: ${NS_API_KEY:-dev-api-key-change-in-production}
WEBHOOK_HOST: dashboard
WEBHOOK_PORT: "3002"
depends_on:
mongo:
condition: service_healthy
api:
condition: service_started
networks:
- ns-network
restart: unless-stopped
volumes:
mongo_data:
mongo_config:
kafka_data:
redis_data:
loki_data:
grafana_data:
plugin-data:
networks:
ns-network:
driver: bridge