forked from margaeor/COMP414-Distributed-Systems
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker-compose-dev.yml
273 lines (259 loc) · 7.15 KB
/
docker-compose-dev.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
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
version: '3.2'
services:
# Authentication
auth:
build:
context: './auth/auth-php/'
dockerfile: Dockerfile.prod
ports:
- "8080:80"
secrets:
- mysql_password
environment:
DB_HOST: "auth-db"
DB_NAME: "${MYSQL_NAME}"
DB_USERNAME: "${MYSQL_USERNAME}"
DB_PASSWORD_FILE: /run/secrets/mysql_password
AUTH_ISSUER: "${AUTH_ISSUER}"
AUTH_PUBLIC: "${AUTH_PUBLIC}"
AUTH_PRIVATE: "${AUTH_PRIVATE}"
#volumes:
# - ./auth/auth-php/src/:/var/www/html/
networks:
- backend
- play_network
container_name: auth
phpmyadmin:
image: phpmyadmin/phpmyadmin:5
secrets:
- mysql_root_password
depends_on:
- auth-db
networks:
- backend
ports:
- "8081:80"
container_name: phpmyadmin
environment:
PMA_HOST: auth-db
PMA_USER: root
PMA_PASSWORD_FILE: /run/secrets/mysql_root_password
# Authentication database
auth-db:
build:
context: './auth/auth-db/'
dockerfile: Dockerfile.dev
args:
MYSQL_VERSION: ${MYSQL_VERSION}
secrets:
- mysql_root_password
- mysql_password
restart: always
ports:
- "3306:3306"
volumes:
- ./auth/auth-db/db_init:/docker-entrypoint-initdb.d
#- data:/var/lib/mysql
networks:
- backend
environment:
MYSQL_ROOT_PASSWORD_FILE: /run/secrets/mysql_root_password
MYSQL_PASSWORD_FILE: /run/secrets/mysql_password
MYSQL_DATABASE: "${MYSQL_NAME}"
MYSQL_USER: "${MYSQL_USERNAME}"
MYSQL_INITDB_SKIP_TZINFO: "yes"
container_name: auth-db
# API
api:
container_name: api
restart: always
image: node:12
working_dir: /home/node/app/
environment:
JWT_PUBLIC_KEY: "${AUTH_PUBLIC}"
MONGODB_USER: '${MONGODB_API_USER}'
MONGODB_DATABASE: '${MONGODB_API_DB}'
MONGODB_REPLICA_SET_NAME: '${MONGODB_REPLICA_SET_NAME}'
MONGODB_REPLICA_SET_MEMBERS: '${MONGODB_REPLICA_SET_MEMBERS}'
PLAYMASTER_IP_PREFIX: '172.21.0.'
volumes:
- ./api/node:/home/node/app
ports:
- "3001:3000"
depends_on:
- mongodb-primary
#- mongodb-secondary
- zookeeper
networks:
- backend
secrets:
- mongodb_api_password
command: bash -c "npm i && npm run dev"
# Mongodb replica set for api
mongodb-primary:
image: 'bitnami/mongodb:4.2'
restart: always
environment:
MONGODB_ADVERTISED_HOSTNAME: mongodb-primary
MONGODB_REPLICA_SET_MODE: primary
MONGODB_ROOT_PASSWORD: '${MONGODB_ROOT_PASSWORD}'
MONGODB_REPLICA_SET_KEY: '${MONGODB_REPLICA_SET_KEY}'
MONGODB_REPLICA_SET_NAME: '${MONGODB_REPLICA_SET_NAME}'
MONGODB_API_USER: '${MONGODB_API_USER}'
MONGODB_API_DB: '${MONGODB_API_DB}'
MONGODB_PLAYMASTER_USER: '${MONGODB_PLAYMASTER_USER}'
MONGODB_PLAYMASTER_DB: '${MONGODB_PLAYMASTER_DB}'
ports:
- "27017:27017"
volumes:
- ./api/mongo/init:/docker-entrypoint-initdb.d
networks:
- backend
secrets:
- mongodb_config
container_name: mongodb-primary
#volumes:
# - 'mongodb_master_data:/bitnami'
mongodb-secondary:
image: 'bitnami/mongodb:4.2'
networks:
- backend
depends_on:
- mongodb-primary
environment:
MONGODB_ADVERTISED_HOSTNAME: mongodb-secondary
MONGODB_REPLICA_SET_MODE: secondary
MONGODB_PRIMARY_HOST: mongodb-primary
# MONGODB_PRIMARY_PORT_NUMBER: '${MONGODB_PRIMARY_PORT_NUMBER}'
MONGODB_PRIMARY_ROOT_PASSWORD: '${MONGODB_ROOT_PASSWORD}'
MONGODB_REPLICA_SET_KEY: '${MONGODB_REPLICA_SET_KEY}'
MONGODB_REPLICA_SET_NAME: '${MONGODB_REPLICA_SET_NAME}'
container_name: mongodb-secondary
mongodb-arbiter:
image: 'bitnami/mongodb:4.2'
networks:
- backend
depends_on:
- mongodb-primary
environment:
MONGODB_ADVERTISED_HOSTNAME: mongodb-arbiter
MONGODB_REPLICA_SET_MODE: arbiter
MONGODB_PRIMARY_HOST: mongodb-primary
#MONGODB_PRIMARY_PORT_NUMBER: '${MONGODB_PRIMARY_PORT_NUMBER}'
MONGODB_PRIMARY_ROOT_PASSWORD: '${MONGODB_ROOT_PASSWORD}'
MONGODB_REPLICA_SET_KEY: '${MONGODB_REPLICA_SET_KEY}'
MONGODB_REPLICA_SET_NAME: '${MONGODB_REPLICA_SET_NAME}'
container_name: mongodb-arbiter
# Others
zookeeper:
image: 'bitnami/zookeeper:3'
networks:
- backend
environment:
ALLOW_ANONYMOUS_LOGIN: "yes"
volumes:
- ./zookeeper/config/zoo.cfg:/opt/bitnami/zookeeper/conf/zoo.cfg
- ./zookeeper/scripts:/opt/zoo/scripts
container_name: zookeeper
#command: /opt/zoo/scripts/init_script.sh
# Playmaster
game:
# build:
# context: './game/'
# dockerfile: Dockerfile.dev
image: node:12
working_dir: /home/node/app/
environment:
JWT_PUBLIC_KEY: "${AUTH_PUBLIC}"
MONGODB_USER: '${MONGODB_PLAYMASTER_USER}'
MONGODB_DATABASE: '${MONGODB_PLAYMASTER_DB}'
MONGODB_REPLICA_SET_NAME: '${MONGODB_REPLICA_SET_NAME}'
MONGODB_REPLICA_SET_MEMBERS: '${MONGODB_REPLICA_SET_MEMBERS}'
PLAY_SUBNET_PREFIX: '192.170.0.'
NODE_ENV: 'development'
PORT: '${GAME_PORT}'
networks:
- backend
- play_network
depends_on:
- zookeeper
volumes:
- ./game:/home/node/app/
secrets:
- mongodb_playmaster_password
container_name: game
command: bash -c "npm i && npm run dev"
# game2:
# # build:
# # context: './game/'
# # dockerfile: Dockerfile.dev
# image: node:12
# working_dir: /home/node/app/
# environment:
# JWT_PUBLIC_KEY: "${AUTH_PUBLIC}"
# MONGODB_USER: '${MONGODB_PLAYMASTER_USER}'
# MONGODB_DATABASE: '${MONGODB_PLAYMASTER_DB}'
# MONGODB_REPLICA_SET_NAME: '${MONGODB_REPLICA_SET_NAME}'
# MONGODB_REPLICA_SET_MEMBERS: '${MONGODB_REPLICA_SET_MEMBERS}'
# PLAY_SUBNET_PREFIX: '192.170.0.'
# NODE_ENV: 'development'
# PORT: '${GAME_PORT}'
# networks:
# - backend
# - play_network
# depends_on:
# - zookeeper
# volumes:
# - ./game:/home/node/app/
# secrets:
# - mongodb_playmaster_password
# container_name: game2
# command: bash -c "npm run dev"
web:
image: nginx
volumes:
- ./web/dist:/usr/share/nginx/html
- ./web/nginx.conf:/etc/nginx/nginx.conf
ports:
- "80:80"
links:
- "game"
# - "game2"
- "auth"
- "api"
- "phpmyadmin"
networks:
- backend
- play_network
container_name: web
web-builder:
image: node:12
working_dir: /home/node/app
environment:
- NODE_ENV=development
volumes:
- ./web/:/home/node/app
networks:
- backend
command: bash -c "npm i; npm run watch"
container_name: web-builder
secrets:
mysql_password:
file: ./secrets/mysql_password
mysql_root_password:
file: ./secrets/mysql_root_password
mongodb_api_password:
file: ./secrets/mongodb_api_password
mongodb_config:
file: ./secrets/mongodb_config
mongodb_playmaster_password:
file: ./secrets/mongodb_playmaster_password
networks:
backend:
play_network:
ipam:
driver: default
config:
- subnet: 192.170.0.0/16
#volumes:
# data: