-
Notifications
You must be signed in to change notification settings - Fork 3
/
docker-compose.yml
210 lines (198 loc) · 5.27 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
version: '3.2'
services:
# Authentication
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}"
depends_on:
- auth-db
# Authentication database
auth-db:
build:
context: './auth/auth-db/'
dockerfile: Dockerfile.prod
args:
MYSQL_VERSION: ${MYSQL_VERSION}
ports:
- "3306"
secrets:
- mysql_root_password
- mysql_password
restart: always
volumes:
- auth-data:/var/lib/mysql
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"
# API
api:
restart: always
ports:
- "3000"
build:
context: './api/node/'
dockerfile: Dockerfile.prod
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.'
depends_on:
- mongodb-primary
- mongodb-secondary
- zookeeper
secrets:
- mongodb_api_password
# Mongodb replica set for api
mongodb-primary:
build:
context: './api/mongo/'
dockerfile: Dockerfile.prod
ports:
- "27017"
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}'
secrets:
- mongodb_config
volumes:
- 'master-data:/bitnami'
mongodb-secondary:
image: 'bitnami/mongodb:latest'
ports:
- "27017"
depends_on:
- mongodb-primary
environment:
MONGODB_ADVERTISED_HOSTNAME: mongodb-secondary
MONGODB_REPLICA_SET_MODE: secondary
MONGODB_PRIMARY_HOST: mongodb-primary
MONGODB_PRIMARY_ROOT_PASSWORD: '${MONGODB_ROOT_PASSWORD}'
MONGODB_REPLICA_SET_KEY: '${MONGODB_REPLICA_SET_KEY}'
MONGODB_REPLICA_SET_NAME: '${MONGODB_REPLICA_SET_NAME}'
mongodb-arbiter:
image: 'bitnami/mongodb:latest'
ports:
- "27017"
depends_on:
- mongodb-primary
environment:
MONGODB_ADVERTISED_HOSTNAME: mongodb-arbiter
MONGODB_REPLICA_SET_MODE: arbiter
MONGODB_PRIMARY_HOST: mongodb-primary
MONGODB_PRIMARY_ROOT_PASSWORD: '${MONGODB_ROOT_PASSWORD}'
MONGODB_REPLICA_SET_KEY: '${MONGODB_REPLICA_SET_KEY}'
MONGODB_REPLICA_SET_NAME: '${MONGODB_REPLICA_SET_NAME}'
# Others
zookeeper:
build:
context: './zookeeper'
dockerfile: Dockerfile.prod
environment:
ALLOW_ANONYMOUS_LOGIN: "yes"
# Playmaster
game:
build:
context: './game/'
dockerfile: Dockerfile.prod
ports:
- "3000"
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.'
PORT: '${GAME_PORT}'
networks:
- default
- play_network
depends_on:
- zookeeper
secrets:
- mongodb_playmaster_password
game2:
build:
context: './game/'
dockerfile: Dockerfile.prod
ports:
- "3000"
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.'
PORT: '${GAME_PORT}'
ports:
- "3000"
networks:
- default
- play_network
depends_on:
- zookeeper
secrets:
- mongodb_playmaster_password
web:
build:
context: './web/'
dockerfile: Dockerfile.prod
ports:
- "80:80"
depends_on:
- auth
- api
- game
- game2
networks:
- default
- play_network
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:
default:
play_network:
ipam:
driver: default
config:
- subnet: 192.170.0.0/16
volumes:
auth-data:
master-data: