Repository navigation
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
308 lines (292 loc) · 9.88 KB
/
Copy pathdocker-compose.yml
File metadata and controls
308 lines (292 loc) · 9.88 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
# The service images copy a jar that Maven has already built, so run
# ./mvnw -B clean package
# before docker compose build, or you will ship yesterday's jar.
services:
flight-db:
image: postgres:17-alpine
container_name: airline-flight-db
environment:
POSTGRES_USER: airline
POSTGRES_PASSWORD: airline
POSTGRES_DB: airline_flight
# Only the host port differs between the databases, so that all of them can
# be reached from a laptop. Inside the network they are all on 5432.
ports:
- "5433:5432"
volumes:
- flight-db-data:/var/lib/postgresql/data
healthcheck:
test: [ "CMD-SHELL", "pg_isready -U airline -d airline_flight" ]
interval: 5s
timeout: 5s
retries: 5
booking-db:
image: postgres:17-alpine
container_name: airline-booking-db
environment:
POSTGRES_USER: airline
POSTGRES_PASSWORD: airline
POSTGRES_DB: airline_booking
ports:
- "5434:5432"
volumes:
- booking-db-data:/var/lib/postgresql/data
healthcheck:
test: [ "CMD-SHELL", "pg_isready -U airline -d airline_booking" ]
interval: 5s
timeout: 5s
retries: 5
payment-db:
image: postgres:17-alpine
container_name: airline-payment-db
environment:
POSTGRES_USER: airline
POSTGRES_PASSWORD: airline
POSTGRES_DB: airline_payment
ports:
- "5435:5432"
volumes:
- payment-db-data:/var/lib/postgresql/data
healthcheck:
test: [ "CMD-SHELL", "pg_isready -U airline -d airline_payment" ]
interval: 5s
timeout: 5s
retries: 5
checkin-db:
image: postgres:17-alpine
container_name: airline-checkin-db
environment:
POSTGRES_USER: airline
POSTGRES_PASSWORD: airline
POSTGRES_DB: airline_checkin
ports:
- "5436:5432"
volumes:
- checkin-db-data:/var/lib/postgresql/data
healthcheck:
test: [ "CMD-SHELL", "pg_isready -U airline -d airline_checkin" ]
interval: 5s
timeout: 5s
retries: 5
notification-db:
image: postgres:17-alpine
container_name: airline-notification-db
environment:
POSTGRES_USER: airline
POSTGRES_PASSWORD: airline
POSTGRES_DB: airline_notification
ports:
- "5437:5432"
volumes:
- notification-db-data:/var/lib/postgresql/data
healthcheck:
test: [ "CMD-SHELL", "pg_isready -U airline -d airline_notification" ]
interval: 5s
timeout: 5s
retries: 5
auth-db:
image: postgres:17-alpine
container_name: airline-auth-db
environment:
POSTGRES_USER: airline
POSTGRES_PASSWORD: airline
POSTGRES_DB: airline_auth
ports:
- "5438:5432"
volumes:
- auth-db-data:/var/lib/postgresql/data
healthcheck:
test: [ "CMD-SHELL", "pg_isready -U airline -d airline_auth" ]
interval: 5s
timeout: 5s
retries: 5
kafka:
image: apache/kafka:4.1.0
container_name: airline-kafka
environment:
# KRaft: one process that is both broker and controller. ZooKeeper stopped
# being required in Kafka 4, and one container is enough for a laptop.
KAFKA_NODE_ID: 1
KAFKA_PROCESS_ROLES: broker,controller
KAFKA_CONTROLLER_QUORUM_VOTERS: 1@kafka:9093
KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:9092,CONTROLLER://0.0.0.0:9093,EXTERNAL://0.0.0.0:29092
# Two advertised listeners because the right address depends on where the
# client stands: kafka:9092 from inside the network, localhost:29092 from
# the host. One value cannot be correct for both.
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092,EXTERNAL://localhost:29092
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,CONTROLLER:PLAINTEXT,EXTERNAL:PLAINTEXT
KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
KAFKA_CONTROLLER_LISTENER_NAMES: CONTROLLER
# One broker, so nothing can be replicated further than itself.
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 1
KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 1
KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS: 0
ports:
- "29092:29092"
volumes:
- kafka-data:/var/lib/kafka/data
healthcheck:
test: [ "CMD-SHELL", "/opt/kafka/bin/kafka-broker-api-versions.sh --bootstrap-server localhost:9092 || exit 1" ]
interval: 5s
timeout: 10s
retries: 15
flight-service:
build: ./flight-service
container_name: airline-flight
environment:
# A development value. Anywhere real this comes from the environment.
BOOKING_SERVICE_TOKEN: ${BOOKING_SERVICE_TOKEN:-a-token-for-development}
SPRING_SECURITY_OAUTH2_RESOURCESERVER_JWT_JWK-SET-URI: http://auth-service:8086/.well-known/jwks.json
SPRING_DATASOURCE_URL: jdbc:postgresql://flight-db:5432/airline_flight
depends_on:
auth-service:
condition: service_healthy
flight-db:
condition: service_healthy
healthcheck:
# wget, not curl: Alpine has the first and not the second.
test: [ "CMD", "wget", "-qO-", "http://localhost:8081/actuator/health" ]
interval: 5s
timeout: 5s
retries: 10
booking-service:
build: ./booking-service
container_name: airline-booking
environment:
BOOKING_SERVICE_TOKEN: ${BOOKING_SERVICE_TOKEN:-a-token-for-development}
SPRING_SECURITY_OAUTH2_RESOURCESERVER_JWT_JWK-SET-URI: http://auth-service:8086/.well-known/jwks.json
SPRING_DATASOURCE_URL: jdbc:postgresql://booking-db:5432/airline_booking
# airline.flight-service.url, as an environment variable. The hyphen in
# the middle is not a typo: Spring relaxes the binding, and there is no
# spelling without it that maps back to the same property.
AIRLINE_FLIGHT-SERVICE_URL: http://flight-service:8081
SPRING_KAFKA_BOOTSTRAP-SERVERS: kafka:9092
depends_on:
auth-service:
condition: service_healthy
booking-db:
condition: service_healthy
# service_healthy, not service_started: booking's first request would fail
# against a flight-service that is up but not yet listening.
flight-service:
condition: service_healthy
kafka:
condition: service_healthy
healthcheck:
test: [ "CMD", "wget", "-qO-", "http://localhost:8082/actuator/health" ]
interval: 5s
timeout: 5s
retries: 10
payment-service:
build: ./payment-service
container_name: airline-payment
environment:
SPRING_SECURITY_OAUTH2_RESOURCESERVER_JWT_JWK-SET-URI: http://auth-service:8086/.well-known/jwks.json
SPRING_DATASOURCE_URL: jdbc:postgresql://payment-db:5432/airline_payment
AIRLINE_BOOKING-SERVICE_URL: http://booking-service:8082
SPRING_KAFKA_BOOTSTRAP-SERVERS: kafka:9092
depends_on:
auth-service:
condition: service_healthy
payment-db:
condition: service_healthy
booking-service:
condition: service_healthy
kafka:
condition: service_healthy
healthcheck:
test: [ "CMD", "wget", "-qO-", "http://localhost:8083/actuator/health" ]
interval: 5s
timeout: 5s
retries: 10
checkin-service:
build: ./checkin-service
container_name: airline-checkin
environment:
SPRING_SECURITY_OAUTH2_RESOURCESERVER_JWT_JWK-SET-URI: http://auth-service:8086/.well-known/jwks.json
SPRING_DATASOURCE_URL: jdbc:postgresql://checkin-db:5432/airline_checkin
AIRLINE_BOOKING-SERVICE_URL: http://booking-service:8082
AIRLINE_FLIGHT-SERVICE_URL: http://flight-service:8081
SPRING_KAFKA_BOOTSTRAP-SERVERS: kafka:9092
depends_on:
auth-service:
condition: service_healthy
checkin-db:
condition: service_healthy
kafka:
condition: service_healthy
booking-service:
condition: service_healthy
flight-service:
condition: service_healthy
healthcheck:
test: [ "CMD", "wget", "-qO-", "http://localhost:8084/actuator/health" ]
interval: 5s
timeout: 5s
retries: 10
notification-service:
build: ./notification-service
container_name: airline-notification
environment:
SPRING_DATASOURCE_URL: jdbc:postgresql://notification-db:5432/airline_notification
SPRING_KAFKA_BOOTSTRAP-SERVERS: kafka:9092
depends_on:
notification-db:
condition: service_healthy
kafka:
condition: service_healthy
healthcheck:
test: [ "CMD", "wget", "-qO-", "http://localhost:8085/actuator/health" ]
interval: 5s
timeout: 5s
retries: 10
auth-service:
build: ./auth-service
container_name: airline-auth
environment:
SPRING_DATASOURCE_URL: jdbc:postgresql://auth-db:5432/airline_auth
depends_on:
auth-db:
condition: service_healthy
healthcheck:
test: [ "CMD", "wget", "-qO-", "http://localhost:8086/actuator/health" ]
interval: 5s
timeout: 5s
retries: 10
api-gateway:
build: ./api-gateway
container_name: airline-gateway
environment:
AIRLINE_JWKS_URI: http://auth-service:8086/.well-known/jwks.json
AIRLINE_AUTH_URI: http://auth-service:8086
AIRLINE_FLIGHTS_URI: http://flight-service:8081
AIRLINE_BOOKINGS_URI: http://booking-service:8082
AIRLINE_PAYMENTS_URI: http://payment-service:8083
AIRLINE_BOARDING_PASSES_URI: http://checkin-service:8084
ports:
- "8080:8080"
depends_on:
auth-service:
condition: service_healthy
flight-service:
condition: service_healthy
booking-service:
condition: service_healthy
payment-service:
condition: service_healthy
checkin-service:
condition: service_healthy
healthcheck:
test: [ "CMD", "wget", "-qO-", "http://localhost:8080/actuator/health" ]
interval: 5s
timeout: 5s
retries: 10
volumes:
flight-db-data:
booking-db-data:
payment-db-data:
checkin-db-data:
notification-db-data:
auth-db-data:
kafka-data: