-
Notifications
You must be signed in to change notification settings - Fork 8
/
docker-compose.yaml
268 lines (253 loc) · 6.49 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
version: "3.9"
services:
user-service:
build:
context: .
dockerfile: Dockerfile.service
args:
service_name: user-service
container_name: user-service
image: user-service
environment:
APP_PORT: 8000
APP_DEBUG: "true"
APP_NAME: user-service
REDIS_URL: "user-cache:6379"
PG_URL: "postgres://postgres:password@postgres:5432/user"
CORS_ORIGINS: "http://localhost:3000,https://localhost:3000"
ports:
- "8000:8000"
restart: unless-stopped # Change for 'always' in production environment
depends_on:
- user-migration
- user-cache
auction-service:
build:
context: .
dockerfile: Dockerfile.service
args:
service_name: auction-service
container_name: auction-service
image: auction-service
environment:
APP_PORT: 8000
APP_DEBUG: "true"
APP_NAME: auction-service
PG_URL: "postgres://postgres:password@postgres:5432/auction"
CORS_ORIGINS: "http://localhost:3000,https://localhost:3000"
ports:
- "8001:8000"
depends_on:
- auction-migration
- zookeeper
- kafka
restart: unless-stopped # Change for 'always' in production environment
bidding-service:
build:
context: .
dockerfile: Dockerfile.service
args:
service_name: bidding-service
container_name: bidding-service
image: bidding-service
environment:
APP_PORT: 8000
APP_DEBUG: "true"
APP_NAME: bidding-service
PG_URL: "postgres://postgres:password@postgres:5432/bidding"
CORS_ORIGINS: "http://localhost:3000,https://localhost:3000"
ports:
- "8002:8000"
depends_on:
- bidding-migration
- zookeeper
- kafka
restart: unless-stopped # Change for 'always' in production environment
request-service:
build:
context: .
dockerfile: Dockerfile.service
args:
service_name: request-service
container_name: request-service
image: request-service
environment:
APP_PORT: 8000
APP_DEBUG: "true"
APP_NAME: request-service
PG_URL: "postgres://postgres:password@postgres:5432/request"
CORS_ORIGINS: "http://localhost:3000,https://localhost:3000"
ports:
- "8003:8000"
depends_on:
- request-migration
- zookeeper
- kafka
restart: unless-stopped # Change for 'always' in production environment
user-migration:
image: migrate/migrate
container_name: user-migration
volumes:
- ./services/user-service/migrations/:/migrations
command:
[
"-path",
"./migrations",
"-database",
"postgres://postgres:password@postgres:5432/user?sslmode=disable",
"up",
]
depends_on:
- postgres
restart: on-failure
request-migration:
image: migrate/migrate
container_name: request-migration
volumes:
- ./services/request-service/migrations/:/migrations
command:
[
"-path",
"./migrations",
"-database",
"postgres://postgres:password@postgres:5432/request?sslmode=disable",
"up",
]
depends_on:
- postgres
restart: on-failure
auction-migration:
image: migrate/migrate
container_name: auction-migration
volumes:
- ./services/auction-service/migrations/:/migrations
command:
[
"-path",
"./migrations",
"-database",
"postgres://postgres:password@postgres:5432/auction?sslmode=disable",
"up",
]
depends_on:
- postgres
restart: on-failure
bidding-migration:
image: migrate/migrate
container_name: bidding-migration
volumes:
- ./services/bidding-service/migrations/:/migrations
command:
[
"-path",
"./migrations",
"-database",
"postgres://postgres:password@postgres:5432/bidding?sslmode=disable",
"up",
]
depends_on:
- postgres
restart: on-failure
postgres:
container_name: postgres
image: postgres
volumes:
- ./scripts/db:/docker-entrypoint-initdb.d
- pg-data:/var/lib/postgresql/data
environment:
- POSTGRES_MULTIPLE_DATABASES=auction,bidding,request
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=password
- POSTGRES_DB=user
ports:
- 5432:5432
adminer:
container_name: adminer
image: adminer
restart: always
ports:
- 8080:8080
user-cache:
container_name: user-cache
image: redis:6.2-alpine
restart: always
ports:
- "6379:6379"
command: redis-server --save 20 1 --loglevel warning
volumes:
- cache:/data
integration:
build:
context: .
dockerfile: Dockerfile.integration
container_name: integration
image: integration
environment:
API_HOST: api-gateway
API_PORT: 80
ENV: DOCKER
depends_on:
- api-gateway
- user-service
- auction-service
- bidding-service
- user-migration
- request-service
- auction-migration
- bidding-migration
- request-migration
- zookeeper
- kafka
restart: on-failure
demo:
build:
context: .
dockerfile: Dockerfile.demo
container_name: demo
image: demo
environment:
API_URL: "api-gateway"
POSTGRES_URL: "postgres://postgres:password@postgres:5432"
depends_on:
integration:
condition: service_completed_successfully
restart: on-failure
api-gateway:
image: nginx
container_name: api-gateway
ports:
- "80:80"
- "443:443"
volumes:
- ./api-gateway/nginx.conf:/etc/nginx/nginx.conf
- ./api-gateway/api_proxy.conf:/etc/nginx/api_proxy.conf
- ./ssl/cert.pem:/etc/ssl/cert.pem
- ./ssl/key.pem:/etc/ssl/key.pem
restart: on-failure
depends_on:
- user-service
- auction-service
- bidding-service
- request-service
- zookeeper
- kafka
zookeeper:
image: wurstmeister/zookeeper
container_name: zookeeper
ports:
- "2181:2181"
kafka:
image: wurstmeister/kafka
container_name: kafka
ports:
- "9092:9092"
environment:
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
KAFKA_ADVERTISED_HOST_NAME: kafka
KAFKA_ADVERTISED_PORT: 9092
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092
KAFKA_CREATE_TOPICS: "request-approved:1:1,bid-created:1:1,auction-updated:1:1"
KAFKA_CONNECT_OFFSET_FLUSH_INTERVAL_MS: 10000 # flush faster than normal
volumes:
pg-data:
cache: