-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
410 lines (386 loc) · 10.1 KB
/
Copy pathdocker-compose.yml
File metadata and controls
410 lines (386 loc) · 10.1 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
410
version: '3.8'
services:
# ==================== INFRASTRUCTURE ====================
# Zookeeper for Kafka
zookeeper:
labels:
service: zookeeper
image: confluentinc/cp-zookeeper:7.5.0
container_name: zookeeper
environment:
ZOOKEEPER_CLIENT_PORT: 2181
ZOOKEEPER_TICK_TIME: 2000
networks:
- microservices
healthcheck:
test: ["CMD", "echo", "ruok", "|", "nc", "localhost", "2181"]
interval: 10s
timeout: 5s
retries: 5
# Kafka
kafka:
labels:
service: kafka
image: confluentinc/cp-kafka:7.5.0
container_name: kafka
depends_on:
zookeeper:
condition: service_healthy
ports:
- "9092:9092"
environment:
KAFKA_BROKER_ID: 1
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
KAFKA_AUTO_CREATE_TOPICS_ENABLE: "true"
networks:
- microservices
healthcheck:
test: ["CMD", "kafka-broker-api-versions", "--bootstrap-server", "localhost:9092"]
interval: 30s
timeout: 10s
retries: 5
kafka-ui:
labels:
service: kafka-ui
image: provectuslabs/kafka-ui:latest
container_name: kafka-ui
ports:
- "8080:8080"
depends_on:
kafka:
condition: service_healthy
environment:
KAFKA_CLUSTERS_0_NAME: "local-kafka"
KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS: kafka:9092
KAFKA_CLUSTERS_0_ZOOKEEPER: zookeeper:2181
networks:
- microservices
# ==================== DATABASES ====================
# PostgreSQL for User Service
postgres-user:
labels:
service: postgres-user
image: postgres:15-alpine
container_name: postgres-user
environment:
POSTGRES_USER: user
POSTGRES_PASSWORD: password
POSTGRES_DB: userdb
ports:
- "5433:5432"
volumes:
- ./data/user:/var/lib/postgresql/data
networks:
- microservices
healthcheck:
test: ["CMD-SHELL", "pg_isready -U user -d userdb"]
interval: 10s
timeout: 5s
retries: 5
# PostgreSQL for Product Service
postgres-product:
labels:
service: postgres-product
image: postgres:15-alpine
container_name: postgres-product
environment:
POSTGRES_USER: user
POSTGRES_PASSWORD: password
POSTGRES_DB: productdb
ports:
- "5434:5432"
volumes:
- ./data/product:/var/lib/postgresql/data
networks:
- microservices
healthcheck:
test: ["CMD-SHELL", "pg_isready -U user -d productdb"]
interval: 10s
timeout: 5s
retries: 5
# PostgreSQL for Payment Service
postgres-payment:
labels:
service: postgres-payment
image: postgres:15-alpine
container_name: postgres-payment
environment:
POSTGRES_USER: user
POSTGRES_PASSWORD: password
POSTGRES_DB: paymentdb
ports:
- "5435:5432"
volumes:
- ./data/payment:/var/lib/postgresql/data
networks:
- microservices
healthcheck:
test: ["CMD-SHELL", "pg_isready -U user -d paymentdb"]
interval: 10s
timeout: 5s
retries: 5
# Redis for Gateway
redis:
labels:
service: redis
image: redis:7-alpine
container_name: redis
ports:
- "6379:6379"
networks:
- microservices
volumes:
- ./data/redis:/data
# command: redis-server --appendonly yes
# ==================== SERVICES ====================
# User Service
user-service:
labels:
service: user-service
build:
context: ./user-service
dockerfile: Dockerfile
image: sleepytmzd/user-service:v3
container_name: user-service
ports:
- "8001:8001"
environment:
DATABASE_URL: postgresql+asyncpg://user:password@postgres-user:5432/userdb
depends_on:
postgres-user:
condition: service_healthy
networks:
- microservices
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8001/health"]
interval: 30s
timeout: 10s
retries: 3
# Product Service
product-service:
labels:
service: product-service
build:
context: ./product-service
dockerfile: Dockerfile
image: sleepytmzd/product-service:v3
container_name: product-service
ports:
- "8002:8002"
- "50051:50051" # gRPC port
environment:
DATABASE_URL: postgresql+asyncpg://user:password@postgres-product:5432/productdb
depends_on:
postgres-product:
condition: service_healthy
networks:
- microservices
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8002/health"]
interval: 30s
timeout: 10s
retries: 3
# Payment Service
payment-service:
labels:
service: payment-service
build:
context: ./payment-service
dockerfile: Dockerfile
image: sleepytmzd/payment-service:v3
container_name: payment-service
ports:
- "8003:8003"
environment:
DATABASE_URL: postgresql+asyncpg://user:password@postgres-payment:5432/paymentdb
KAFKA_BOOTSTRAP_SERVERS: kafka:9092
depends_on:
postgres-payment:
condition: service_healthy
kafka:
condition: service_healthy
networks:
- microservices
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8003/health"]
interval: 30s
timeout: 10s
retries: 3
# Order Service
order-service:
labels:
service: order-service
build:
context: ./order-service
dockerfile: Dockerfile
image: sleepytmzd/order-service:v3
container_name: order-service
ports:
- "8004:8004"
environment:
# PRODUCT_SERVICE_URL: http://product-service:8002
# PAYMENT_SERVICE_URL: http://payment-service:8003
# NOTIFICATION_SERVICE_URL: http://notification-service:8005
PRODUCT_SERVICE_GRPC_URL: product-service:50051
KAFKA_BOOTSTRAP_SERVERS: kafka:9092
depends_on:
- product-service
- payment-service
- notification-service
networks:
- microservices
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8004/health"]
interval: 30s
timeout: 10s
retries: 3
# Notification Service
notification-service:
labels:
service: notification-service
build:
context: ./notification-service
dockerfile: Dockerfile
image: sleepytmzd/notification-service:v3
container_name: notification-service
ports:
- "8005:8005"
environment:
KAFKA_BOOTSTRAP_SERVERS: kafka:9092
depends_on:
kafka:
condition: service_healthy
networks:
- microservices
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8005/health"]
interval: 30s
timeout: 10s
retries: 3
# API Gateway
api-gateway:
labels:
service: api-gateway
build:
context: ./api-gateway
dockerfile: Dockerfile
image: sleepytmzd/ecom-api-gateway:v3
container_name: ecom-api-gateway
ports:
- "8000:8000"
environment:
JWT_SECRET: your-super-secret-jwt-key-change-in-production
REDIS_URL: redis://redis:6379
USER_SERVICE_URL: http://user-service:8001
PRODUCT_SERVICE_URL: http://product-service:8002
PAYMENT_SERVICE_URL: http://payment-service:8003
ORDER_SERVICE_URL: http://order-service:8004
NOTIFICATION_SERVICE_URL: http://notification-service:8005
depends_on:
- redis
- user-service
- product-service
- payment-service
- order-service
- notification-service
networks:
- microservices
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
interval: 30s
timeout: 10s
retries: 3
# ==================== MONITORING ====================
prometheus:
image: prom/prometheus:latest
container_name: prometheus
volumes:
- ./monitoring/prometheus.yml:/etc/prometheus/prometheus.yml
ports:
- "9090:9090"
networks:
- microservices
depends_on:
- user-service
- product-service
- payment-service
- order-service
- notification-service
- api-gateway
grafana:
image: grafana/grafana:latest
container_name: grafana
ports:
- "3000:3000"
environment:
GF_SECURITY_ADMIN_USER: admin
GF_SECURITY_ADMIN_PASSWORD: admin
volumes:
- ./monitoring/grafana/provisioning:/var/lib/grafana/provisioning
- ./monitoring/grafana/provisioning/dashboards:/etc/grafana/provisioning/dashboards
depends_on:
- prometheus
networks:
- microservices
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:8.6.2
container_name: elasticsearch
environment:
- discovery.type=single-node
- xpack.security.enabled=false
- ES_JAVA_OPTS=-Xms512m -Xmx512m
ports:
- "9200:9200"
volumes:
- ./data/elasticsearch:/usr/share/elasticsearch/data
networks:
- microservices
logstash:
image: docker.elastic.co/logstash/logstash:8.6.2
container_name: logstash
volumes:
- ./monitoring/logstash/pipeline/logstash.conf:/usr/share/logstash/pipeline/logstash.conf
ports:
- "5044:5044"
depends_on:
- elasticsearch
networks:
- microservices
kibana:
image: docker.elastic.co/kibana/kibana:8.6.2
container_name: kibana
ports:
- "5601:5601"
environment:
ELASTICSEARCH_HOSTS: http://elasticsearch:9200
depends_on:
- elasticsearch
networks:
- microservices
fluent-bit:
image: fluent/fluent-bit:latest
container_name: fluent-bit
user: root
volumes:
- /var/lib/docker/containers:/var/lib/docker/containers:ro
- /var/run/docker.sock:/var/run/docker.sock:ro
- ./monitoring/fluent-bit/fluent-bit.conf:/fluent-bit/etc/fluent-bit.conf
- ./data/fluent-bit-storage:/fluent-bit/storage
ports:
- "2020:2020"
- "2021:2021"
depends_on:
- logstash
networks:
- microservices
networks:
microservices:
driver: bridge