-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
385 lines (343 loc) · 11 KB
/
Copy pathdocker-compose.yml
File metadata and controls
385 lines (343 loc) · 11 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
# workers will be built on app images
# defined once and reuse
x-worker-base: &worker-base
build:
context: .
dockerfile: Dockerfile
env_file:
- .env
depends_on:
mysql:
condition: service_healthy
redis:
condition: service_healthy
kafka:
condition: service_healthy
elasticsearch:
condition: service_healthy
backend:
condition: service_healthy
restart: unless-stopped
# services are defined
services:
# mysql db
mysql:
image: mysql:8.4
container_name: irtc-mysql
ports:
- "3307:3306"
environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
MYSQL_DATABASE: ${MYSQL_DB_NAME}
MYSQL_USER: ${MYSQL_DB_USER}
MYSQL_PASSWORD: ${MYSQL_DB_PASSWORD}
env_file:
- .env
volumes:
- mysql_data:/var/lib/mysql
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
interval: 10s
timeout: 5s
retries: 10
restart: unless-stopped
# UI for view mysql db
phpmyadmin:
image: phpmyadmin/phpmyadmin
container_name: irtc-phpmyadmin
ports:
- "8080:80"
environment:
PMA_HOST: mysql
PMA_PORT: 3306
depends_on:
mysql:
condition: service_healthy
restart: unless-stopped
# redis
redis:
image: redis:7.2
container_name: irtc-redis
ports:
- "6380:6379"
volumes:
- redis_data:/data
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 10
restart: unless-stopped
# kafka (using Kraft)
kafka:
image: apache/kafka:3.9.0
container_name: irtc-kafka
ports:
- "9092:9092"
environment:
KAFKA_NODE_ID: 1
KAFKA_PROCESS_ROLES: broker,controller
KAFKA_LISTENERS: PLAINTEXT://:9092,CONTROLLER://:9093
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092
KAFKA_CONTROLLER_LISTENER_NAMES: CONTROLLER
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT
KAFKA_CONTROLLER_QUORUM_VOTERS: 1@kafka:9093
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: "true"
volumes:
- kafka_data:/var/lib/kafka/data
healthcheck:
test: ["CMD-SHELL", "nc -z localhost 9092 || exit 1"]
interval: 15s
timeout: 5s
retries: 10
restart: unless-stopped
# creating kafka topics which required by applications
kafka-init:
image: apache/kafka:3.9.0
container_name: irtc-kafka-init
depends_on:
kafka:
condition: service_healthy
command: >
sh -c '
echo "Waiting for Kafka...";
sleep 10;
create_topic() {
/opt/kafka/bin/kafka-topics.sh --bootstrap-server kafka:9092 --create --if-not-exists --topic "$1" --partitions 6 --replication-factor 1;
};
create_topic pwdchanged-otp;
create_topic emailverification-otp;
create_topic emailchanged-otp;
create_topic station;
create_topic route;
create_topic schedule;
create_topic schedule-inventory-seat-availability-updated;
create_topic payment-updated-status;
create_topic booking-updated-status;
echo "All Kafka topics creation completed.";
'
restart: "no"
# elastic searches
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:8.15.1
container_name: irtc-elasticsearch
ports:
- "9200:9200"
environment:
- discovery.type=single-node
- xpack.security.enabled=false
- ES_JAVA_OPTS=-Xms512m -Xmx512m
healthcheck:
test: ["CMD-SHELL", "curl -s http://localhost:9200 >/dev/null || exit 1"]
interval: 10s
timeout: 10s
retries: 20
restart: unless-stopped
# UI for elastic search for CRUD
kibana:
image: docker.elastic.co/kibana/kibana:8.15.1
container_name: irtc-kibana
ports:
- "5601:5601"
environment:
- ELASTICSEARCH_HOSTS=http://elasticsearch:9200
depends_on:
elasticsearch:
condition: service_healthy
restart: unless-stopped
# main application code building the packages/images
# right now is by-pass
backend:
build:
context: .
dockerfile: Dockerfile
container_name: irtc-backend
ports:
- "8000:8000"
env_file:
- .env
volumes:
- ./logs:/app/logs
- ./perf:/app/perf
depends_on:
mysql:
condition: service_healthy
redis:
condition: service_healthy
kafka:
condition: service_healthy
elasticsearch:
condition: service_healthy
healthcheck:
test: ["CMD-SHELL", "wget --spider -q http://localhost:8000/docs || exit 1"]
interval: 10s
timeout: 5s
retries: 20
restart: unless-stopped
# dummy backend and this service will be used with another services as per required dependencies
backend-dummy:
profiles:
- backend
image: alpine
command: sh -c "while true; do sleep 1000; done"
healthcheck:
test: ["CMD", "true"]
# applications all different types background workers
# background workers for password changed
pwdchanged-otp-outbox-worker:
<<: *worker-base
container_name: irtc-pwdchanged-otp-outbox-worker
depends_on:
backend:
condition: service_healthy
command: python -m app.workers.outbox.pwdchanged_otp_outbox_worker
pwdchanged-otp-outbox-dispatcher:
<<: *worker-base
container_name: irtc-pwdchanged-otp-outbox-dispatcher
depends_on:
backend:
condition: service_healthy
command: python -m app.infrastructure.outbox.dispatchers.pwdchanged_otp_outbox_dispatcher
# background workers for email changed
emailchanged-otp-outbox-worker:
<<: *worker-base
container_name: irtc-emailchanged-otp-outbox-worker
depends_on:
backend:
condition: service_healthy
command: python -m app.workers.outbox.emailchanged_otp_outbox_worker
emailchanged-otp-outbox-dispatcher:
<<: *worker-base
container_name: irtc-emailchanged-otp-outbox-dispatcher
depends_on:
backend:
condition: service_healthy
command: python -m app.infrastructure.outbox.dispatchers.emailchanged_otp_outbox_dispatcher
# background workers for email verification
emailverification-otp-outbox-worker:
<<: *worker-base
container_name: irtc-emailverification-otp-outbox-worker
depends_on:
backend:
condition: service_healthy
command: python -m app.workers.outbox.emailverification_otp_outbox_worker
emailverification-otp-outbox-dispatcher:
<<: *worker-base
container_name: irtc-emailverification-otp-outbox-dispatcher
depends_on:
backend:
condition: service_healthy
command: python -m app.infrastructure.outbox.dispatchers.emailverification_otp_outbox_dispatcher
# background workers for stations
stations-outbox-worker:
<<: *worker-base
container_name: irtc-stations-outbox-worker
depends_on:
backend:
condition: service_healthy
command: python -m app.workers.outbox.stations_outbox_worker
stations-outbox-dispatcher:
<<: *worker-base
container_name: irtc-stations-outbox-dispatcher
depends_on:
backend:
condition: service_healthy
command: python -m app.infrastructure.outbox.dispatchers.stations_outbox_dispatcher
# background workers for routes
routes-outbox-worker:
<<: *worker-base
container_name: irtc-routes-outbox-worker
depends_on:
backend:
condition: service_healthy
command: python -m app.workers.outbox.routes_outbox_worker
routes-outbox-dispatcher:
<<: *worker-base
container_name: irtc-routes-outbox-dispatcher
depends_on:
backend:
condition: service_healthy
command: python -m app.infrastructure.outbox.dispatchers.routes_outbox_dispatcher
# background workers for schedules
schedules-outbox-worker:
<<: *worker-base
container_name: irtc-schedules-outbox-worker
depends_on:
backend:
condition: service_healthy
command: python -m app.workers.outbox.schedules_outbox_worker
schedules-outbox-dispatcher:
<<: *worker-base
container_name: irtc-schedules-outbox-dispatcher
depends_on:
backend:
condition: service_healthy
command: python -m app.infrastructure.outbox.dispatchers.schedules_outbox_dispatcher
# background workers for schedules inventory
schedule-inventory-outbox-worker:
<<: *worker-base
container_name: irtc-schedule-inventory-outbox-worker
depends_on:
backend:
condition: service_healthy
command: python -m app.workers.outbox.schedules_inventory_worker
schedule-inventory-outbox-dispatcher:
<<: *worker-base
container_name: irtc-schedule-inventory-outbox-dispatcher
depends_on:
backend:
condition: service_healthy
command: python -m app.infrastructure.outbox.dispatchers.schedules_inventory_dispatcher
# background workers for schedules inventory seat availability updated
schedule-inventory-seat-availability-updated-outbox-worker:
<<: *worker-base
container_name: irtc-schedule-inventory-seat-availability-updated-outbox-worker
depends_on:
backend:
condition: service_healthy
command: python -m app.workers.outbox.schedule_inventory_seat_availability_outbox_worker
schedule-inventory-seat-availability-updated-outbox-dispatcher:
<<: *worker-base
container_name: irtc-schedule-inventory-seat-availability-updated-outbox-dispatcher
depends_on:
backend:
condition: service_healthy
command: python -m app.infrastructure.outbox.dispatchers.schedule_inventory_seat_availability_updated_outbox_dispatcher
# background workers for payment orders updated status
payment-updated-status-outbox-worker:
<<: *worker-base
container_name: irtc-payment-updated-status-outbox-worker
depends_on:
backend:
condition: service_healthy
command: python -m app.workers.outbox.payment_orders_updated_status_outbox_worker
payment-updated-status-outbox-dispatcher:
<<: *worker-base
container_name: irtc-payment-updated-status-outbox-dispatcher
depends_on:
backend:
condition: service_healthy
command: python -m app.infrastructure.outbox.dispatchers.payment_orders_updated_status_outbox_dispatcher
# background workers for booking updated status
booking-updated-status-outbox-worker:
<<: *worker-base
container_name: irtc-booking-updated-status-outbox-worker
depends_on:
backend:
condition: service_healthy
command: python -m app.workers.outbox.booking_updated_status_outbox_worker
booking-updated-status-send-email-outbox-dispatcher:
<<: *worker-base
container_name: irtc-booking-updated-status-send-email-outbox-dispatcher
depends_on:
backend:
condition: service_healthy
command: python -m app.infrastructure.outbox.dispatchers.booking_updated_status_send_email_outbox_dispatcher
# volumes config
volumes:
mysql_data:
redis_data:
kafka_data: