-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-compose.yml
246 lines (218 loc) · 6.61 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
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
#
# University of Pisa - Advanced Software Engineering - 2021-2022
# Main docker-compose File
# Project:
#┌─────────────────────────────────────────────────────────────────────────────────────────┐
#│ __ __ _ ____ _ _ _ │
#│ | \/ | ___ ___ ___ __ _ __ _ ___ (_)_ __ __ _ | __ ) ___ | |_| |_| | ___ │
#│ | |\/| |/ _ \/ __/ __|/ _` |/ _` |/ _ \ | | '_ \ / _` | | _ \ / _ \| __| __| |/ _ \ │
#│ | | | | __/\__ \__ \ (_| | (_| | __/ | | | | | | (_| | | |_) | (_) | |_| |_| | __/ │
#│ |_| |_|\___||___/___/\__,_|\__, |\___| |_|_| |_| \__,_| |____/ \___/ \__|\__|_|\___| │
#│ |___/ │
#└─────────────────────────────────────────────────────────────────────────────────────────┘
version: '3.8'
services:
# -------------------------------------------- #
# Starting with API Gateway and Load Balancer #
# -------------------------------------------- #
nginx_lb_orchestrator:
#
# Nginx Orchestrator instance
#
container_name: load_balancer_orchestrator
restart: always
build: ./mib-api-gateway/nginx-orchestrator
volumes:
- /var/run/docker.sock:/var/run/docker.sock # WARNING: with Winzozz it does not work, but we need it!
- nginx_conf:/etc/nginx/conf.d
nginx_lb:
#
# Nginx single instance
#
container_name: load_balancer
restart: always
build: ./mib-api-gateway/nginx
labels:
- mib.nginx_lb
volumes:
- nginx_conf:/etc/nginx/conf.d
- static_contents:/static
ports:
- "80:80"
api_gateway:
#
# API Gateway
#
# ! ! ! WARNING ! ! !
# DO NOT set the container_name attribute and ports mapping
# to allow the replication.
#
restart: always
build: ./mib-api-gateway
volumes:
- static_contents:/static
env_file:
- gateway.conf
environment:
- USERS_MS_HOST=users_ms_worker
- BLACKLIST_MS_HOST=blacklist_ms_worker
- MESSAGES_MS_HOST=messages_ms_worker
labels:
- mib.api_gateway_worker
# -------------------------------------------- #
# Common Services #
# -------------------------------------------- #
# -------------------------------------------- #
# Users Microservice #
# -------------------------------------------- #
users_ms_db:
#
# Users Microservice Database
#
image: library/postgres:10
restart: on-failure
env_file:
- users_ms.conf
healthcheck:
test: [ "CMD-SHELL", "pg_isready -U $$POSTGRES_USER" ]
interval: 10s
timeout: 5s
retries: 5
users_ms_worker:
#
# Users Microservice Worker node
#
build: ./mib-users
restart: on-failure
env_file:
- users_ms.conf
environment:
- POSTGRES_HOST=users_ms_db
- BLACKLIST_MS_HOST=blacklist_ms_worker
- MESSAGES_MS_HOST=messages_ms_worker
depends_on:
users_ms_db:
condition: service_healthy
ports:
- "5001:5001"
# -------------------------------------------- #
# Blacklist Microservice #
# -------------------------------------------- #
blacklist_ms_db:
#
# Blacklist Microservice Database
#
image: library/postgres:10
restart: on-failure
env_file:
- blacklist_ms.conf
healthcheck:
test: [ "CMD-SHELL", "pg_isready -U $$POSTGRES_USER" ]
interval: 10s
timeout: 5s
retries: 5
blacklist_ms_worker:
#
# Blacklist Microservice Worker node
#
build: ./mib-blacklist
restart: on-failure
env_file:
- blacklist_ms.conf
environment:
- POSTGRES_HOST=blacklist_ms_db
- USERS_MS_HOST=users_ms_worker
- MESSAGES_MS_HOST=messages_ms_worker
depends_on:
blacklist_ms_db:
condition: service_healthy
ports:
- "5002:5002"
# -------------------------------------------- #
# Messages Microservice #
# -------------------------------------------- #
messages_ms_db:
#
# Messages Microservice Database
#
image: library/postgres:10
restart: on-failure
env_file:
- messages_ms.conf
healthcheck:
test: [ "CMD-SHELL", "pg_isready -U $$POSTGRES_USER" ]
interval: 10s
timeout: 5s
retries: 5
messages_ms_worker:
#
# Messages Microservice Worker node
#
build: ./mib-messages
restart: on-failure
env_file:
- messages_ms.conf
environment:
- POSTGRES_HOST=messages_ms_db
- USERS_MS_HOST=users_ms_worker
- BLACKLIST_MS_HOST=blacklist_ms_worker
depends_on:
messages_ms_db:
condition: service_healthy
ports:
- "5003:5003"
#
# Specify here your microservices
# separating services by: db_service, migration_service, worker_service
#
# -------------------------------------------- #
# Celery and redis #
# -------------------------------------------- #
messages_celery:
container_name: messages_celery
build:
context: ./mib-messages
dockerfile: Dockerfile-celery
env_file:
- messages_ms.conf
environment:
- POSTGRES_HOST=messages_ms_db
- USERS_MS_HOST=users_ms_worker
- BLACKLIST_MS_HOST=blacklist_ms_worker
depends_on:
- redis_messages
links:
- redis_messages
redis_messages:
container_name: redis_messages
image: "redis:alpine"
ports:
- "6378:6379"
users_celery:
container_name: users_celery
build:
context: ./mib-users
dockerfile: Dockerfile-celery
env_file:
- users_ms.conf
environment:
- POSTGRES_HOST=users_ms_db
- BLACKLIST_MS_HOST=blacklist_ms_worker
- MESSAGES_MS_HOST=messages_ms_worker
depends_on:
- redis_users
links:
- redis_users
redis_users:
container_name: redis_users
image: "redis:alpine"
ports:
- "6379:6379"
volumes:
# -------------------------------------------- #
# Volumes #
# -------------------------------------------- #
nginx_conf:
# Nginx configuration volume
static_contents:
# API Gateway static content volume