-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathdocker-compose.yml
113 lines (104 loc) · 3.35 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
version: "3.7"
services:
# public port 80, the only port exposed
web:
restart: always
build:
context: ./frontend
dockerfile: Dockerfile.nginx
args:
USE_NPM_MIRROR: "yes"
ports:
- "80:80"
depends_on:
- "backend"
# api address on 0.0.0.0:8000
backend:
restart: always
build:
context: ./backend
dockerfile: Dockerfile.django
args:
USE_PIP_MIRROR: "yes"
USE_APK_MIRROR: "yes"
USE_MYSQL: "yes"
environment:
VERILOG_OJ_HOST_STATIC: "yes"
#VERILOG_OJ_PROD_DEBUG: "yes"
VERILOG_OJ_JUDGER_SECRET: ${judger_secret}
VERILOG_OJ_SECRET_KEY: ${secret_key}
VERILOG_OJ_USE_MYSQL: "yes"
VERILOG_OJ_MYSQL_DATABASE: django_db
VERILOG_OJ_MYSQL_HOST: db
VERILOG_OJ_MYSQL_PORT: 3306
VERILOG_OJ_MYSQL_USER: django
VERILOG_OJ_MYSQL_PASSWORD: ${mysql_password}
VERILOG_OJ_PUBLIC_HOST: ${public_host}
VERILOG_OJ_RABBITMQ_PASSWORD: ${rabbitmq_password}
DOCKER_JUDGER_HOST_PATH: ${docker_judger_host_path}
DOCKER_HOST_DIR: ${docker_host_dir}
volumes:
- files-volume:/app/storage
depends_on:
- "db"
- "mqserver"
- "judgeworker" # consumer starts first
# Fix bug on Django entering Chinese characters
# - The database connection settings only works with conn params
# - And not on anything else
# - Useful command: `show variables like 'character%';` in mysql
# ref: https://stackoverflow.com/questions/45729326/how-to-change-the-default-character-set-of-mysql-using-docker-compose
db:
restart: always
# 5.7 raises InnoDB limit, so VARCHAR(255) is possible
# - So no need to alter Django stuff, probably
# - http://mysql.rjweb.org/doc.php/limits#767_limit_in_innodb_indexes
image: "mysql:5.7"
# Notice the env below will only useful when no db file is given
environment:
MYSQL_ROOT_PASSWORD: ${mysql_root_password}
MYSQL_DATABASE: django_db
MYSQL_USER: django
MYSQL_PASSWORD: ${mysql_password}
volumes:
- db-volume:/var/lib/mysql
command: ['mysqld', '--character-set-server=utf8mb4', '--collation-server=utf8mb4_unicode_ci']
mqserver:
restart: always
image: "rabbitmq:3.8-management"
environment:
RABBITMQ_DEFAULT_USER: user
RABBITMQ_DEFAULT_PASS: ${rabbitmq_password}
judgeworker:
restart: always
build:
context: ./backend
dockerfile: Dockerfile.judger
args:
USE_PIP_MIRROR: "yes"
USE_APT_MIRROR: "yes"
USE_MYSQL: "yes"
environment:
VERILOG_OJ_JUDGER_SECRET: ${judger_secret}
VERILOG_OJ_SECRET_KEY: ${secret_key}
VERILOG_OJ_USE_MYSQL: "yes"
VERILOG_OJ_MYSQL_DATABASE: django_db
VERILOG_OJ_MYSQL_HOST: db
VERILOG_OJ_MYSQL_PORT: 3306
VERILOG_OJ_MYSQL_USER: django
VERILOG_OJ_MYSQL_PASSWORD: ${mysql_password}
VERILOG_OJ_PUBLIC_HOST: ${public_host}
VERILOG_OJ_RABBITMQ_PASSWORD: ${rabbitmq_password}
DOCKER_JUDGER_HOST_PATH: ${docker_judger_host_path}
DOCKER_HOST_DIR: ${docker_host_dir}
depends_on:
- "mqserver"
# Bind mount to control host docker & map a dir so host can fetch easily
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ${docker_judger_host_path}:${docker_host_dir}
volumes:
db-volume:
driver: local
files-volume:
driver: local