-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathcompose.yaml
271 lines (270 loc) · 7.42 KB
/
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
269
270
271
networks:
outside:
inside:
internal: true
services:
# 中间件
mysql:
container_name: "${COMPOSE_PROJECT_NAME}_mysql" # specify container name to disable scalability
image: mysql:8.0
env_file:
- ./env/mysql/mysql.env
cap_add:
- SYS_NICE # solve the 'mbind: Operation not permitted' error
volumes:
- ./env/mysql/conf/:/etc/mysql/conf.d/
- ./env/mysql/initdb/:/docker-entrypoint-initdb.d/
- ./data/mysql/data/:/var/lib/mysql/
- ./data/mysql/files/:/var/lib/mysql-files/
# 如需暴露端口,取消 ports 和 outside 的注释
# ports:
# - "3306:3306"
networks:
inside:
aliases:
- sduoj-mysql
# outside:
deploy:
restart_policy:
condition: any
redis:
container_name: "${COMPOSE_PROJECT_NAME}_redis" # specify container name to disable scalability
image: redis:alpine
# 如需暴露端口,取消 ports 和 outside 的注释
# ports:
# - "6379:6379"
networks:
inside:
aliases:
- sduoj-redis
# outside:
deploy:
restart_policy:
condition: any
rabbit:
container_name: "${COMPOSE_PROJECT_NAME}_rabbit" # specify container name to disable scalability
image: rabbitmq:management
env_file:
- ./env/rabbitmq/rabbitmq.env
# 如需暴露端口,取消 ports 和 outside 的注释
# ports:
# - "5672:5672"
# - "15672:15672"
networks:
inside:
aliases:
- sduoj-rabbit
# outside:
deploy:
restart_policy:
condition: any
nacos:
container_name: "${COMPOSE_PROJECT_NAME}_nacos" # specify container name to disable scalability
build:
context: build/sduoj-nacos/2.1.2
env_file:
- ./env/nacos/nacos.env
volumes:
- ./data/nacos/logs/:/home/nacos/logs/
# 如需暴露端口,取消 ports 和 outside 的注释
# ports:
# - "${NACOS_PORT8848}:8848"
# - "${NACOS_PORT9848}:9848"
# - "${NACOS_PORT9849}:9849"
networks:
inside:
aliases:
- sduoj-nacos
# outside:
environment:
WAIT_HOSTS: sduoj-mysql:3306
deploy:
restart_policy:
condition: any
# 前端
frontend:
container_name: "${COMPOSE_PROJECT_NAME}_frontend" # specify container name to disable scalability
build:
context: build/sduoj-frontend/latest
environment:
DOMAIN_NAME: ${DOMAIN_NAME}
volumes:
- ./env/frontend/nginx.conf:/etc/nginx/nginx.conf:ro
# 如需暴露 https,配置相应 ./env/frontend/ssl 目录下两个证书文件,并取消下面的注释
# - ./env/frontend/ssl.conf:/etc/nginx/conf.d/ssl.conf:ro
# - ./env/frontend/ssl/:/etc/nginx/ssl/:ro
ports:
- "${FRONTEND_PORT80}:80"
# 如需暴露 https 的 443 端口,取消下面的注释
# - "${FRONTEND_PORT443}:443"
networks:
inside:
aliases:
- sduoj-frontend
outside:
deploy:
restart_policy:
condition: any
# 后端网关
gateway:
container_name: "${COMPOSE_PROJECT_NAME}_gateway" # specify container name to disable scalability
image: registry.cn-beijing.aliyuncs.com/sduoj/sduoj-server
volumes:
- ./data/sduoj/logs/:/root/sduoj/logs/
environment:
WAIT_HOSTS: sduoj-nacos:8848,sduoj-redis:6379
NACOS_ADDR: sduoj-nacos:8848
ACTIVE: prod
SERVICE: gateway
networks:
inside:
aliases:
- sduoj-gateway
deploy:
resources:
limits:
memory: 2048M
restart_policy:
condition: on-failure
# 后端微服务
auth-service:
image: registry.cn-beijing.aliyuncs.com/sduoj/sduoj-server
volumes:
- ./data/sduoj/logs/:/root/sduoj/logs/
environment:
WAIT_HOSTS: sduoj-mysql:3306,sduoj-nacos:8848
NACOS_ADDR: sduoj-nacos:8848
ACTIVE: prod
SERVICE: auth
networks:
inside:
deploy:
resources:
limits:
memory: 2048M
restart_policy:
condition: on-failure
contest-service:
image: registry.cn-beijing.aliyuncs.com/sduoj/sduoj-server
volumes:
- ./data/sduoj/logs/:/root/sduoj/logs/
environment:
WAIT_HOSTS: sduoj-mysql:3306,sduoj-nacos:8848,sduoj-redis:6379
NACOS_ADDR: sduoj-nacos:8848
ACTIVE: prod
SERVICE: contest
networks:
inside:
deploy:
resources:
limits:
memory: 2048M
restart_policy:
condition: on-failure
filesys-service:
image: registry.cn-beijing.aliyuncs.com/sduoj/sduoj-server
volumes:
- ./data/sduoj/logs/:/root/sduoj/logs/
- ./data/sduoj/filesys/:/root/sduoj/filesys/
environment:
WAIT_HOSTS: sduoj-mysql:3306,sduoj-nacos:8848
NACOS_ADDR: sduoj-nacos:8848
ACTIVE: prod
SERVICE: filesys
networks:
inside:
deploy:
resources:
limits:
memory: 2048M
restart_policy:
condition: on-failure
problem-service:
image: registry.cn-beijing.aliyuncs.com/sduoj/sduoj-server
volumes:
- ./data/sduoj/logs/:/root/sduoj/logs/
environment:
WAIT_HOSTS: sduoj-mysql:3306,sduoj-nacos:8848,sduoj-redis:6379,sduoj-rabbit:5672
NACOS_ADDR: sduoj-nacos:8848
ACTIVE: prod
SERVICE: problem
networks:
inside:
deploy:
resources:
limits:
memory: 2048M
restart_policy:
condition: on-failure
submit-service:
image: registry.cn-beijing.aliyuncs.com/sduoj/sduoj-server
volumes:
- ./data/sduoj/logs/:/root/sduoj/logs/
environment:
WAIT_HOSTS: sduoj-mysql:3306,sduoj-nacos:8848,sduoj-redis:6379,sduoj-rabbit:5672
NACOS_ADDR: sduoj-nacos:8848
ACTIVE: prod
SERVICE: submit
networks:
inside:
deploy:
resources:
limits:
memory: 2048M
restart_policy:
condition: on-failure
user-service:
image: registry.cn-beijing.aliyuncs.com/sduoj/sduoj-server
volumes:
- ./data/sduoj/logs/:/root/sduoj/logs/
environment:
WAIT_HOSTS: sduoj-mysql:3306,sduoj-nacos:8848,sduoj-redis:6379,sduoj-rabbit:5672
NACOS_ADDR: sduoj-nacos:8848
ACTIVE: prod
SERVICE: user
# make sure this service is registered via the inside network IP; use 'eth1' because inside NIC will be ordered last
JAVA_OPT_EXT: --spring.cloud.nacos.discovery.networkInterface=eth1
networks:
inside:
# user-service needs to connect to the SMTP server, so it needs to be connected to the outside network
outside:
deploy:
resources:
limits:
memory: 2048M
restart_policy:
condition: on-failure
websocket-service:
image: registry.cn-beijing.aliyuncs.com/sduoj/sduoj-server
volumes:
- ./data/sduoj/logs/:/root/sduoj/logs/
environment:
WAIT_HOSTS: sduoj-nacos:8848,sduoj-redis:6379,sduoj-rabbit:5672
NACOS_ADDR: sduoj-nacos:8848
ACTIVE: prod
SERVICE: websocket
networks:
inside:
deploy:
resources:
limits:
memory: 2048M
restart_policy:
condition: on-failure
# 评测机
judger:
image: registry.cn-beijing.aliyuncs.com/sduoj/sduoj-judger
environment:
WAIT_HOSTS: sduoj-nacos:8848,sduoj-rabbit:5672
NACOS_ADDR: sduoj-nacos:8848
ACTIVE: prod
networks:
inside:
cpuset: "0"
deploy:
resources:
limits:
memory: 1536M
pids: 1024
restart_policy:
condition: on-failure