-
Notifications
You must be signed in to change notification settings - Fork 18
/
docker-compose.yaml
551 lines (521 loc) · 14.5 KB
/
docker-compose.yaml
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
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
version: '3.2'
networks:
mongo:
driver: bridge
redis:
driver: bridge
rabbitmq:
driver: bridge
ory:
driver: bridge
apps:
driver: bridge
volumes:
mongo_volume:
redis_volume:
rabbitmq_volume:
kratos_postgres_volume:
hydra_postgres_volume:
keto_postgres_volume:
services:
# region Storage
mongo-primary:
image: mongo:7
container_name: ticketing-mongo-primary
hostname: ticketing-mongo-primary
volumes:
- mongo_volume:/data/db
networks:
- mongo
ports:
- '${MONGO_PORT:-27017}:27017'
command: mongod --replSet rs0
healthcheck:
test: |
mongosh --eval "try { rs.status().ok } catch (e) { rs.initiate({ _id: 'rs0', members: [{ _id: 0, host: 'localhost:27017' }] }).ok }"
start_period: 0s
interval: 500ms
timeout: 5s
retries: 5
profiles:
- 'deps-only'
- 'dev'
redis:
image: redis:alpine
container_name: ticketing-redis
hostname: ticketing-redis
volumes:
- redis_volume:/data
networks:
- redis
ports:
- '${REDIS_PORT:-6379}:6379'
mem_limit: 256m
memswap_limit: 512m
restart: always
profiles:
- 'deps-only'
- 'dev'
# endregion
# region RabbitMQ
rabbitmq:
image: rabbitmq:3.12-management-alpine
container_name: 'ticketing-rabbitmq'
hostname: ticketing-rabbitmq
healthcheck:
test: ['CMD', 'rabbitmq-diagnostics', 'status']
interval: '10s'
timeout: '15s'
start_period: '30s'
retries: 3
volumes:
- ./infra/rabbitmq/etc/rabbitmq.conf:/etc/rabbitmq/rabbitmq.conf
# - ./infra/rabbitmq/etc/definitions.json:/etc/rabbitmq/definitions.json
- ./infra/rabbitmq/etc/enabled_plugins:/etc/rabbitmq/enabled_plugins
- rabbitmq_volume:/var/lib/rabbitmq/mnesia/rabbit@ticketing-rabbitmq
ports:
- ${RABBITMQ_PORT:-5672}:5672
- ${RABBITMQ_MGT_PORT:-15672}:15672
- ${RABBITMQ_MQTT_PORT:-1883}:1883
- ${RABBITMQ_WS_PORT:-15675}:15675
networks:
- rabbitmq
restart: always
profiles:
- 'deps-only'
- 'dev'
# for docker on linux
# extra_hosts:
# - "host.docker.internal:host-gateway"
# endregion
# region micro services
auth-service:
image: 'ghcr.io/getlarge/ticketing-auth:${AUTH_IMAGE_VERSION:-latest}'
container_name: auth-service
hostname: auth-service
environment:
NODE_ENV: ${NODE_ENV:-development}
LOG_LEVEL: ${LOG_LEVEL:-info}
PORT: ${AUTH_HTTP_PORT:-3000}
SERVER_URL: http://localhost:${AUTH_HTTP_PORT:-3000}
PROXY_SERVER_URLS: ${PROXY_SERVER_URLS:-http://ticketing.dev}
FRONTEND_URL: ${FRONTEND_URL:-http://ticketing.dev}
JWT_ALGORITHM: ${JWT_ALGORITHM:-ES256}
JWT_EXPIRES_IN: ${JWT_EXPIRES_IN:-60m}
JWT_ISSUER: ${JWT_ISSUER:-ticketing.dev}
JWT_PRIVATE_KEY: ${JWT_PRIVATE_KEY}
JWT_PUBLIC_KEY: ${JWT_PUBLIC_KEY}
SESSION_KEY: ${SESSION_KEY}
RMQ_URL: http://ticketing-rabbitmq:5672
MONGODB_URI: mongodb://ticketing-mongo-primary:27017/auth
ORY_ACTION_API_KEY: ${ORY_ACTION_API_KEY}
ORY_API_KEY: ${ORY_API_KEY}
ORY_BASE_PATH: ${ORY_BASE_PATH}
healthcheck:
test: node ./healthcheck.js http://0.0.0.0:${AUTH_HTTP_PORT:-3000}/$GLOBAL_API_PREFIX/health
interval: 60s
timeout: 3s
start_period: 10s
retries: 2
depends_on:
- mongo-primary
- rabbitmq
ports:
- '${AUTH_HTTP_PORT:-3000}:${AUTH_HTTP_PORT:-3000}'
networks:
- mongo
- rabbitmq
- apps
mem_limit: 256m
memswap_limit: 512m
restart: always
profiles:
- 'services-only'
- 'dev'
expiration-service:
image: 'ghcr.io/getlarge/ticketing-expiration:${EXPIRATION_IMAGE_VERSION:-latest}'
container_name: expiration-service
hostname: expiration-service
environment:
NODE_ENV: ${NODE_ENV:-development}
LOG_LEVEL: ${LOG_LEVEL:-info}
PORT: ${EXPIRATION_HTTP_PORT:-3030}
SERVER_URL: http://localhost:${EXPIRATION_HTTP_PORT:-3030}
PROXY_SERVER_URLS: ${PROXY_SERVER_URLS:-http://ticketing.dev}
RMQ_URL: http://ticketing-rabbitmq:5672
REDIS_URL: redis://ticketing-redis:6379
ORY_API_KEY: ${ORY_API_KEY}
ORY_BASE_PATH: ${ORY_BASE_PATH}
healthcheck:
test: node ./healthcheck.js http://0.0.0.0:${EXPIRATION_HTTP_PORT:-3000}/${GLOBAL_API_PREFIX:-api}/health
interval: 60s
timeout: 3s
start_period: 10s
retries: 2
depends_on:
- redis
- rabbitmq
ports:
- '${EXPIRATION_HTTP_PORT:-3030}:${EXPIRATION_HTTP_PORT:-3030}'
networks:
- redis
- rabbitmq
- apps
mem_limit: 256m
memswap_limit: 512m
restart: always
profiles:
- 'services-only'
- 'dev'
orders-service:
image: 'ghcr.io/getlarge/ticketing-orders:${ORDERS_IMAGE_VERSION:-latest}'
container_name: orders-service
hostname: orders-service
environment:
NODE_ENV: ${NODE_ENV:-development}
LOG_LEVEL: ${LOG_LEVEL:-info}
PORT: ${ORDERS_HTTP_PORT:-3020}
SERVER_URL: http://localhost:${ORDERS_HTTP_PORT:-3020}
PROXY_SERVER_URLS: ${PROXY_SERVER_URLS:-http://ticketing.dev}
FRONTEND_URL: ${FRONTEND_URL:-http://ticketing.dev}
JWT_ALGORITHM: ${JWT_ALGORITHM:-ES256}
JWT_EXPIRES_IN: ${JWT_EXPIRES_IN:-60m}
JWT_ISSUER: ${JWT_ISSUER:-ticketing.dev}
JWT_PRIVATE_KEY: ${JWT_PRIVATE_KEY}
JWT_PUBLIC_KEY: ${JWT_PUBLIC_KEY}
SESSION_KEY: ${SESSION_KEY}
RMQ_URL: http://ticketing-rabbitmq:5672
MONGODB_URI: mongodb://ticketing-mongo-primary:27017/orders
ORY_API_KEY: ${ORY_API_KEY}
ORY_BASE_PATH: ${ORY_BASE_PATH}
healthcheck:
test: node ./healthcheck.js http://0.0.0.0:${ORDERS_HTTP_PORT:-3020}/${GLOBAL_API_PREFIX:-api}/health
interval: 60s
timeout: 3s
start_period: 10s
retries: 2
depends_on:
- mongo-primary
- rabbitmq
ports:
- '${ORDERS_HTTP_PORT:-3020}:${ORDERS_HTTP_PORT:-3020}'
networks:
- mongo
- rabbitmq
- apps
mem_limit: 256m
memswap_limit: 512m
restart: always
profiles:
- 'services-only'
- 'dev'
payments-service:
image: 'ghcr.io/getlarge/ticketing-payments:${PAYMENTS_IMAGE_VERSION:-latest}'
container_name: payments-service
hostname: payments-service
environment:
NODE_ENV: ${NODE_ENV:-development}
LOG_LEVEL: ${LOG_LEVEL:-info}
PORT: ${PAYMENTS_HTTP_PORT:-3040}
SERVER_URL: http://localhost:${PAYMENTS_HTTP_PORT:-3040}
PROXY_SERVER_URLS: ${PROXY_SERVER_URLS:-http://ticketing.dev}
FRONTEND_URL: ${FRONTEND_URL:-http://ticketing.dev}
JWT_ALGORITHM: ${JWT_ALGORITHM:-ES256}
JWT_EXPIRES_IN: ${JWT_EXPIRES_IN:-60m}
JWT_ISSUER: ${JWT_ISSUER:-ticketing.dev}
JWT_PRIVATE_KEY: ${JWT_PRIVATE_KEY}
JWT_PUBLIC_KEY: ${JWT_PUBLIC_KEY}
SESSION_KEY: ${SESSION_KEY}
RMQ_URL: http://ticketing-rabbitmq:5672
MONGODB_URI: mongodb://ticketing-mongo-primary:27017/payments
STRIPE_PUBLISHABLE_KEY: ${STRIPE_PUBLISHABLE_KEY}
STRIPE_SECRET_KEY: ${STRIPE_SECRET_KEY}
STRIPE_ENDPOINT_SECRET: ${STRIPE_ENDPOINT_SECRET}
ORY_API_KEY: ${ORY_API_KEY}
ORY_BASE_PATH: ${ORY_BASE_PATH}
healthcheck:
test: node ./healthcheck.js http://0.0.0.0:${PAYMENTS_HTTP_PORT:-3040}/${GLOBAL_API_PREFIX:-api}/health
interval: 60s
timeout: 3s
start_period: 10s
retries: 2
depends_on:
- mongo-primary
- rabbitmq
ports:
- '${PAYMENTS_HTTP_PORT:-3040}:${PAYMENTS_HTTP_PORT:-3040}'
networks:
- mongo
- rabbitmq
- apps
mem_limit: 256m
memswap_limit: 512m
restart: always
profiles:
- 'services-only'
- 'dev'
tickets-service:
image: 'ghcr.io/getlarge/ticketing-tickets:${TICKETS_IMAGE_VERSION:-latest}'
container_name: tickets-service
hostname: tickets-service
environment:
NODE_ENV: ${NODE_ENV:-development}
LOG_LEVEL: ${LOG_LEVEL:-info}
PORT: ${TICKETS_HTTP_PORT:-3010}
SERVER_URL: http://localhost:${TICKETS_HTTP_PORT:-3010}
PROXY_SERVER_URLS: ${PROXY_SERVER_URLS:-http://ticketing.dev}
FRONTEND_URL: ${FRONTEND_URL:-http://ticketing.dev}
JWT_ALGORITHM: ${JWT_ALGORITHM:-ES256}
JWT_EXPIRES_IN: ${JWT_EXPIRES_IN:-60m}
JWT_ISSUER: ${JWT_ISSUER:-ticketing.dev}
JWT_PRIVATE_KEY: ${JWT_PRIVATE_KEY}
JWT_PUBLIC_KEY: ${JWT_PUBLIC_KEY}
SESSION_KEY: ${SESSION_KEY}
RMQ_URL: http://ticketing-rabbitmq:5672
MONGODB_URI: mongodb://ticketing-mongo-primary:27017/tickets
ORY_API_KEY: ${ORY_API_KEY}
ORY_BASE_PATH: ${ORY_BASE_PATH}
healthcheck:
test: node ./healthcheck.js http://0.0.0.0:${TICKETS_HTTP_PORT:-3010}/${GLOBAL_API_PREFIX:-api}/health
interval: 60s
timeout: 3s
start_period: 10s
retries: 2
depends_on:
- mongo-primary
- rabbitmq
ports:
- '${TICKETS_HTTP_PORT:-3010}:${TICKETS_HTTP_PORT:-3010}'
networks:
- mongo
- rabbitmq
- apps
mem_limit: 256m
memswap_limit: 512m
restart: always
profiles:
- 'services-only'
- 'dev'
# endregion
# region Frontend
ng-client:
image: 'ghcr.io/getlarge/ticketing-ng-client:${CLIENT_IMAGE_VERSION:-latest}'
container_name: ng-client
hostname: ng-client
healthcheck:
test: curl -f http://localhost:4200
ports:
- '4200:4200'
networks:
- apps
mem_limit: 256m
memswap_limit: 512m
restart: always
profiles:
- 'services-only'
- 'dev'
nginx:
container_name: ticketing-nginx
build:
context: infra/nginx
dockerfile: Dockerfile
args:
- TEMPLATE=nginx.template
environment:
- DOMAIN=${DOMAIN:-localhost}
- FRONTEND_PORT=3000
- FRONTEND=ng-client
- AUTH_SERVICE=auth-service
- ORDERS_SERVICE=orders-service
- PAYMENTS_SERVICE=payments-service
- TICKETS_SERVICE=tickets-service
- AUTH_SERVICE_PORT=${AUTH_SERVICE_PORT:-3000}
- ORDERS_SERVICE_PORT=${ORDERS_SERVICE_PORT:-3020}
- PAYMENTS_SERVICE_PORT=${PAYMENTS_SERVICE_PORT:-3040}
- TICKETS_SERVICE_PORT=${TICKETS_SERVICE_PORT:-3010}
depends_on:
ng-client:
condition: service_started
auth-service:
condition: service_started
orders-service:
condition: service_started
payments-service:
condition: service_started
tickets-service:
condition: service_started
# condition: service_healthy
networks:
- apps
ports:
- '127.0.0.1:${NGINX_HTTP_PORT:-8800}:8080'
restart: always
profiles:
- 'services-only'
- 'dev'
# for docker on linux
# extra_hosts:
# - "host.docker.internal:host-gateway"
# endregion
# region Ory Kratos
kratos-migrate:
image: oryd/kratos:v1.1.0
volumes:
- ./infra/ory/kratos:/etc/config/kratos:ro
command: -c /etc/config/kratos/kratos.yaml migrate sql -e --yes
restart: on-failure
networks:
- ory
profiles:
- 'ory-only'
- 'dev'
kratos:
depends_on:
- kratos-migrate
image: oryd/kratos:v1.1.0
ports:
- '4433:4433' # public
- '4434:4434' # admin
restart: unless-stopped
command: serve -c /etc/config/kratos/kratos.yaml --dev --watch-courier
volumes:
- ./infra/ory/kratos:/etc/config/kratos:ro
networks:
- ory
profiles:
- 'ory-only'
- 'dev'
# for docker on linux
# extra_hosts:
# - "host.docker.internal:host-gateway"
kratos-postgres:
image: postgres:16
environment:
- POSTGRES_USER=dbuser
- POSTGRES_PASSWORD=secret
- POSTGRES_DB=kratosdb
volumes:
- kratos_postgres_volume:/var/lib/postgresql/data
networks:
- ory
profiles:
- 'ory-only'
- 'dev'
kratos-selfservice-ui-node:
image: oryd/kratos-selfservice-ui-node:v1.1.0
environment:
- KRATOS_PUBLIC_URL=http://kratos:4433
- KRATOS_BROWSER_URL=http://127.0.0.1:4433
- HYDRA_ADMIN_URL=http://hydra:4445
- KRATOS_ADMIN_URL=http://kratos:4434
- PORT=4455
- COOKIE_SECRET=changeme
- CSRF_COOKIE_NAME=cookie_name
- CSRF_COOKIE_SECRET=changeme
- DANGEROUSLY_DISABLE_SECURE_CSRF_COOKIES=true
ports:
- '4455:4455'
networks:
- ory
restart: on-failure
profiles:
- 'ory-only'
- 'dev'
mailslurper:
image: oryd/mailslurper:latest-smtps
ports:
- '4436:4436'
- '4437:4437'
networks:
- ory
profiles:
- 'ory-only'
- 'dev'
# endregion
#region Hydra
hydra-migrate:
image: oryd/hydra:v2.2.0
command: migrate -c /etc/config/hydra/hydra.yaml sql -e --yes
volumes:
- ./infra/ory/hydra:/etc/config/hydra:ro
restart: on-failure
networks:
- ory
profiles:
- 'ory-only'
- 'dev'
hydra:
image: oryd/hydra:v2.2.0
ports:
- '4444:4444' # public
- '4445:4445' # admin
- '5555:5555' # port to use for OAuth2 redirect URIs
command: serve -c /etc/config/hydra/hydra.yaml all --dev
volumes:
- ./infra/ory/hydra:/etc/config/hydra:ro
restart: unless-stopped
depends_on:
- hydra-migrate
networks:
- ory
profiles:
- 'ory-only'
- 'dev'
hydra-postgres:
image: postgres:16
environment:
- POSTGRES_USER=dbuser
- POSTGRES_PASSWORD=secret
- POSTGRES_DB=hydradb
volumes:
- hydra_postgres_volume:/var/lib/postgresql/data
networks:
- ory
profiles:
- 'ory-only'
- 'dev'
# endregion
# region Ory Keto
keto-migrate:
image: oryd/keto:v0.12.0
volumes:
- ./infra/ory/keto:/etc/config/keto:ro
- ./tools/ory/namespaces.ts:/home/ory/namespaces.ts
command: ['migrate', 'up', '-y', '-c', '/etc/config/keto/keto.yaml']
restart: on-failure
networks:
- ory
profiles:
- 'ory-only'
- 'dev'
keto:
depends_on:
- keto-migrate
image: oryd/keto:v0.12.0
ports:
- '4466:4466' # public
- '4467:4467' # admin
command: serve -c /etc/config/keto/keto.yaml
restart: unless-stopped
volumes:
- ./infra/ory/keto:/etc/config/keto:ro
- ./tools/ory/namespaces.ts:/home/ory/namespaces.ts
networks:
- ory
profiles:
- 'ory-only'
- 'dev'
keto-postgres:
image: postgres:16
environment:
- POSTGRES_USER=dbuser
- POSTGRES_PASSWORD=secret
- POSTGRES_DB=accesscontroldb
volumes:
- keto_postgres_volume:/var/lib/postgresql/data
networks:
- ory
profiles:
- 'ory-only'
- 'dev'
# endregion