-
Notifications
You must be signed in to change notification settings - Fork 3
/
docker-compose-swarm.yml
239 lines (225 loc) · 6.34 KB
/
docker-compose-swarm.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
version: '3.2'
services:
# Authentication
auth:
image: '${CONTAINER_REGISTRY}/auth'
build:
context: './auth/auth-php/'
dockerfile: Dockerfile.prod
ports:
- "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}"
links:
- auth-db
networks:
- backend
container_name: auth
# phpmyadmin:
# image: phpmyadmin/phpmyadmin:latest
# secrets:
# - mysql_root_password
# links:
# - auth-db
# networks:
# - frontend
# - 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:
image: '${CONTAINER_REGISTRY}/authdb'
build:
context: './auth/auth-db/'
dockerfile: Dockerfile.prod
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
- auth-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: '${CONTAINER_REGISTRY}/api'
build:
context: './api/node/'
dockerfile: Dockerfile.prod
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: comp414_mongodb-primary,comp414_mongodb-secondary
PLAYMASTER_IP_PREFIX: '172.21.0.'
volumes:
- ./api/node:/home/node/app
ports:
- "3000"
depends_on:
- mongodb-primary
- mongodb-secondary
- zookeeper
networks:
- backend
secrets:
- mongodb_api_password
# Others
zookeeper:
image: '${CONTAINER_REGISTRY}/zookeeper'
build:
context: './zookeeper'
dockerfile: Dockerfile.prod
networks:
- backend
environment:
ALLOW_ANONYMOUS_LOGIN: "yes"
container_name: zookeeper
# Playmaster
game:
image: '${CONTAINER_REGISTRY}/playmaster'
build:
context: './game/'
dockerfile: Dockerfile.prod
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: comp414_mongodb-primary,comp414_mongodb-secondary
PLAY_SUBNET_PREFIX: '192.170.0.'
NODE_ENV: 'development'
PORT: '${GAME_PORT}'
deploy:
replicas: 2
networks:
- backend
- play_network
links:
- zookeeper
secrets:
- mongodb_playmaster_password
container_name: game
web:
image: '${CONTAINER_REGISTRY}/nginx'
build:
context: './web/'
dockerfile: Dockerfile.swarm
ports:
- "80:80"
links:
- "game"
- "auth"
- "api"
networks:
- backend
- play_network
container_name: web
# Mongodb replica set for api
mongodb-primary:
image: '${CONTAINER_REGISTRY}/mongodb-primary'
build:
context: './api/mongo/'
dockerfile: Dockerfile.prod
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"
networks:
- backend
secrets:
- mongodb_config
container_name: mongodb-primary
#volumes:
#- '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
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:
ipam:
driver: default
play_network:
ipam:
driver: default
config:
- subnet: 192.170.0.0/16
volumes:
auth-data:
master-data: