-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdocker-compose.yml
199 lines (186 loc) · 4.49 KB
/
docker-compose.yml
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
version: "3"
services:
zookeeper:
image: confluentinc/cp-zookeeper:latest
container_name: zookeeper
environment:
ZOOKEEPER_CLIENT_PORT: 2181
ZOOKEEPER_TICK_TIME: 2000
ports:
- 22181:2181
- 2181:2181
networks:
- ecommerce
kafka:
image: confluentinc/cp-kafka:latest
container_name: kafka
depends_on:
- zookeeper
ports:
- 29092:29092
- 9092:9092
environment:
KAFKA_BROKER_ID: 1
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092,PLAINTEXT_HOST://localhost:29092
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
networks:
- ecommerce
postgres:
image: postgres:14.2
restart: always
container_name: postgres
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=accounts
- POSTGRES_PORT=5432
ports:
- "5432:5432"
volumes:
- db:/var/lib/postgresql/data
healthcheck:
test: ["CMD", "pg_isready", "-U", "postgres", "-d", "accounts"]
interval: 30s
timeout: 60s
retries: 5
start_period: 80s
networks:
- ecommerce
mongo_db:
image: mongo:6-jammy
container_name: mongo_db
restart: on-failure
ports:
- "27017:27017"
volumes:
- dbdata6:/data/db
networks:
- ecommerce
healthcheck:
test: echo 'db.runCommand("ping").ok' | mongosh localhost:27017/test --quiet | grep 1
interval: 5s
timeout: 5s
retries: 5
start_period: 10s
serviceregistry:
build:
context: ./serviceregistry
dockerfile: Dockerfile
image: ecommerce/serviceregistry
container_name: serviceregistry
ports:
- "8761:8761"
healthcheck:
test: "curl --fail --silent localhost:8761/actuator/health | grep UP || exit 1"
interval: 2s
timeout: 3s
retries: 5
networks:
- ecommerce
apigateway:
build:
context: ./apigateway
dockerfile: Dockerfile
image: ecommerce/apigateway
container_name: apigateway
ports:
- "8084:8084"
depends_on:
serviceregistry:
condition: service_healthy
links:
- serviceregistry
healthcheck:
test: "curl --fail --silent localhost:8084/actuator/health | grep UP || exit 1"
interval: 2s
timeout: 3s
retries: 5
networks:
- ecommerce
id_generator:
build:
context: ./id.generator
dockerfile: Dockerfile
image: ecommerce/id_generator
container_name: id_generator
ports:
- "8082:8082"
depends_on:
serviceregistry:
condition: service_healthy
apigateway:
condition: service_healthy
links:
- serviceregistry
healthcheck:
test: "curl --fail --silent localhost:8082/actuator/health | grep UP || exit 1"
interval: 2s
timeout: 3s
retries: 5
networks:
- ecommerce
accounts:
build:
context: ./accounts
dockerfile: Dockerfile
image: ecommerce/accounts
container_name: accounts
restart: on-failure
ports:
- "8081:8081"
environment:
- DATABASE_URL=jdbc:postgresql://postgres:5432/accounts
- REGISTRY_SERVICE_URL=http://serviceregistry:8761/eureka
- POSTGRES_USERNAME=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=accounts
- POSTGRES_PORT=5432
- POSTGRES_HOST=postgres
env_file:
- .env
depends_on:
serviceregistry:
condition: service_healthy
postgres:
condition: service_healthy
apigateway:
condition: service_healthy
id_generator:
condition: service_healthy
links:
- serviceregistry
networks:
- ecommerce
products:
build:
context: ./products
dockerfile: Dockerfile
image: ecommerce/products
restart: on-failure
container_name: products
ports:
- "8083:8083"
depends_on:
serviceregistry:
condition: service_healthy
apigateway:
condition: service_healthy
mongo_db:
condition: service_healthy
links:
- mongo_db
networks:
- ecommerce
environment:
- REGISTRY_SERVICE_URL=http://serviceregistry:8761/eureka
- PRODUCT_DATABASE_URL=mongodb://mongo_db:27017/products
volumes:
db:
driver: local
dbdata6:
networks:
ecommerce:
name: ecommerce