-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
409 lines (386 loc) · 11.9 KB
/
Copy pathdocker-compose.yml
File metadata and controls
409 lines (386 loc) · 11.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
version: "3.9"
# ─────────────────────────────────────────────
# Networks
# ─────────────────────────────────────────────
networks:
oidc-net:
driver: bridge
# ─────────────────────────────────────────────
# Volumes
# ─────────────────────────────────────────────
volumes:
mongodb-auth-data:
mongodb-client-data:
mongodb-oidc-data:
mongodb-uma-data:
mongodb-scope-data:
# ─────────────────────────────────────────────
# Services
# ─────────────────────────────────────────────
services:
# ── MongoDB instances (one per bounded context) ──────────────────────────
mongodb-auth:
image: mongo:7.0
container_name: mongodb-auth
restart: unless-stopped
ports:
- "27017:27017"
environment:
MONGO_INITDB_DATABASE: auth_db
volumes:
- mongodb-auth-data:/data/db
networks:
- oidc-net
healthcheck:
test: ["CMD", "mongosh", "--eval", "db.adminCommand('ping')"]
interval: 10s
timeout: 5s
retries: 5
mongodb-client:
image: mongo:7.0
container_name: mongodb-client
restart: unless-stopped
ports:
- "27018:27017"
environment:
MONGO_INITDB_DATABASE: client_db
volumes:
- mongodb-client-data:/data/db
networks:
- oidc-net
healthcheck:
test: ["CMD", "mongosh", "--eval", "db.adminCommand('ping')"]
interval: 10s
timeout: 5s
retries: 5
mongodb-oidc:
image: mongo:7.0
container_name: mongodb-oidc
restart: unless-stopped
ports:
- "27019:27017"
environment:
MONGO_INITDB_DATABASE: oidc_db
volumes:
- mongodb-oidc-data:/data/db
networks:
- oidc-net
healthcheck:
test: ["CMD", "mongosh", "--eval", "db.adminCommand('ping')"]
interval: 10s
timeout: 5s
retries: 5
mongodb-uma:
image: mongo:7.0
container_name: mongodb-uma
restart: unless-stopped
ports:
- "27020:27017"
environment:
MONGO_INITDB_DATABASE: uma_db
volumes:
- mongodb-uma-data:/data/db
networks:
- oidc-net
healthcheck:
test: ["CMD", "mongosh", "--eval", "db.adminCommand('ping')"]
interval: 10s
timeout: 5s
retries: 5
mongodb-scope:
image: mongo:7.0
container_name: mongodb-scope
restart: unless-stopped
ports:
- "27021:27017"
environment:
MONGO_INITDB_DATABASE: scope_db
volumes:
- mongodb-scope-data:/data/db
networks:
- oidc-net
healthcheck:
test: ["CMD", "mongosh", "--eval", "db.adminCommand('ping')"]
interval: 10s
timeout: 5s
retries: 5
# ── Kafka (KRaft mode — no Zookeeper) ────────────────────────────────────
kafka:
image: apache/kafka:3.7.0
container_name: kafka
restart: unless-stopped
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_QUORUM_VOTERS: 1@kafka:9093
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,CONTROLLER:PLAINTEXT
KAFKA_CONTROLLER_LISTENER_NAMES: CONTROLLER
KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 1
KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 1
KAFKA_AUTO_CREATE_TOPICS_ENABLE: "false"
CLUSTER_ID: "MkU3OEVBNTcwNTJENDM2Qk"
networks:
- oidc-net
healthcheck:
test: ["CMD", "/opt/kafka/bin/kafka-broker-api-versions.sh", "--bootstrap-server", "localhost:9092"]
interval: 15s
timeout: 10s
retries: 10
# Creates all required topics (including DLTs) after Kafka is healthy
kafka-init:
image: apache/kafka:3.7.0
container_name: kafka-init
depends_on:
kafka:
condition: service_healthy
networks:
- oidc-net
entrypoint: ["/bin/sh", "-c"]
command:
- |
KAFKA=/opt/kafka/bin/kafka-topics.sh
BS=kafka:9092
for TOPIC in \
auth.token.issued \
auth.token.revoked \
auth.refresh.issued \
auth.refresh.revoked \
client.registered \
client.updated \
client.deleted \
uma.resource.registered \
uma.permission.created; do
$$KAFKA --bootstrap-server $$BS --create --if-not-exists --topic $$TOPIC --partitions 3 --replication-factor 1
$$KAFKA --bootstrap-server $$BS --create --if-not-exists --topic $${TOPIC}.DLT --partitions 1 --replication-factor 1
done
echo "All topics created."
restart: "no"
# ── Microservices ─────────────────────────────────────────────────────────
scope-manager:
build:
context: .
dockerfile: scope-manager/Dockerfile
container_name: scope-manager
restart: unless-stopped
ports:
- "8084:8084"
environment:
MONGODB_URI: mongodb://mongodb-scope:27017/scope_db
SERVER_PORT: "8084"
depends_on:
mongodb-scope:
condition: service_healthy
networks:
- oidc-net
healthcheck:
test: ["CMD", "wget", "-qO-", "http://localhost:8084/actuator/health"]
interval: 15s
timeout: 5s
retries: 10
client-registry:
build:
context: .
dockerfile: client-registry/Dockerfile
container_name: client-registry
restart: unless-stopped
ports:
- "8081:8081"
environment:
MONGODB_URI: mongodb://mongodb-client:27017/client_db
KAFKA_BOOTSTRAP_SERVERS: kafka:9092
SERVER_PORT: "8081"
SCOPE_MANAGER_URL: http://scope-manager:8084
depends_on:
mongodb-client:
condition: service_healthy
kafka:
condition: service_healthy
kafka-init:
condition: service_completed_successfully
scope-manager:
condition: service_healthy
networks:
- oidc-net
healthcheck:
test: ["CMD", "wget", "-qO-", "http://localhost:8081/actuator/health"]
interval: 15s
timeout: 5s
retries: 10
authorization-server:
build:
context: .
dockerfile: authorization-server/Dockerfile
container_name: authorization-server
restart: unless-stopped
ports:
- "8080:8080"
environment:
MONGODB_URI: mongodb://mongodb-auth:27017/auth_db
KAFKA_BOOTSTRAP_SERVERS: kafka:9092
SERVER_PORT: "8080"
SCOPE_MANAGER_URL: http://scope-manager:8084
CLIENT_REGISTRY_URL: http://client-registry:8081
depends_on:
mongodb-auth:
condition: service_healthy
kafka:
condition: service_healthy
kafka-init:
condition: service_completed_successfully
scope-manager:
condition: service_healthy
client-registry:
condition: service_healthy
networks:
- oidc-net
healthcheck:
test: ["CMD", "wget", "-qO-", "http://localhost:8080/actuator/health"]
interval: 15s
timeout: 5s
retries: 10
oidc-provider:
build:
context: .
dockerfile: oidc-provider/Dockerfile
container_name: oidc-provider
restart: unless-stopped
ports:
- "8082:8082"
environment:
MONGODB_URI: mongodb://mongodb-oidc:27017/oidc_db
KAFKA_BOOTSTRAP_SERVERS: kafka:9092
SERVER_PORT: "8082"
AUTHORIZATION_SERVER_URL: http://authorization-server:8080
depends_on:
mongodb-oidc:
condition: service_healthy
kafka:
condition: service_healthy
kafka-init:
condition: service_completed_successfully
authorization-server:
condition: service_healthy
networks:
- oidc-net
healthcheck:
test: ["CMD", "wget", "-qO-", "http://localhost:8082/actuator/health"]
interval: 15s
timeout: 5s
retries: 10
uma-server:
build:
context: .
dockerfile: uma-server/Dockerfile
container_name: uma-server
restart: unless-stopped
ports:
- "8083:8083"
environment:
MONGODB_URI: mongodb://mongodb-uma:27017/uma_db
KAFKA_BOOTSTRAP_SERVERS: kafka:9092
SERVER_PORT: "8083"
depends_on:
mongodb-uma:
condition: service_healthy
kafka:
condition: service_healthy
kafka-init:
condition: service_completed_successfully
authorization-server:
condition: service_healthy
networks:
- oidc-net
healthcheck:
test: ["CMD", "wget", "-qO-", "http://localhost:8083/actuator/health"]
interval: 15s
timeout: 5s
retries: 10
api-gateway:
build:
context: .
dockerfile: api-gateway/Dockerfile
container_name: api-gateway
restart: unless-stopped
ports:
- "8443:8443"
- "8090:8090"
environment:
SERVER_PORT: "8090"
AUTHORIZATION_SERVER_URL: http://authorization-server:8080
CLIENT_REGISTRY_URL: http://client-registry:8081
OIDC_PROVIDER_URL: http://oidc-provider:8082
UMA_SERVER_URL: http://uma-server:8083
SCOPE_MANAGER_URL: http://scope-manager:8084
depends_on:
authorization-server:
condition: service_healthy
client-registry:
condition: service_healthy
oidc-provider:
condition: service_healthy
uma-server:
condition: service_healthy
scope-manager:
condition: service_healthy
networks:
- oidc-net
# ── MongoDB Seed (run-once, idempotent) ──────────────────────────────────
mongo-seed:
image: mongo:7.0
container_name: mongo-seed
restart: "no"
depends_on:
mongodb-scope:
condition: service_healthy
mongodb-client:
condition: service_healthy
mongodb-oidc:
condition: service_healthy
volumes:
- ./mongo-seed:/seed:ro
networks:
- oidc-net
entrypoint: ["/bin/bash", "-c"]
command:
- |
echo "→ Seeding scope_db..."
mongosh --host mongodb-scope:27017 --quiet /seed/01-seed-scopes.js
echo "→ Seeding client_db..."
mongosh --host mongodb-client:27017 --quiet /seed/02-seed-clients.js
echo "→ Seeding oidc_db..."
mongosh --host mongodb-oidc:27017 --quiet /seed/03-seed-users.js
echo "=== Seed concluído ==="
# ── Migration Tool (run-once) ─────────────────────────────────────────────
migration-tool:
build:
context: .
dockerfile: migration-tool/Dockerfile
container_name: migration-tool
restart: "no"
environment:
MONGODB_AUTH_URI: mongodb://mongodb-auth:27017/auth_db
MONGODB_CLIENT_URI: mongodb://mongodb-client:27017/client_db
MONGODB_OIDC_URI: mongodb://mongodb-oidc:27017/oidc_db
MONGODB_UMA_URI: mongodb://mongodb-uma:27017/uma_db
MONGODB_SCOPE_URI: mongodb://mongodb-scope:27017/scope_db
depends_on:
mongodb-auth:
condition: service_healthy
mongodb-client:
condition: service_healthy
mongodb-oidc:
condition: service_healthy
mongodb-uma:
condition: service_healthy
mongodb-scope:
condition: service_healthy
networks:
- oidc-net
profiles:
- migration