forked from codalab/codabench
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
316 lines (304 loc) · 9.27 KB
/
docker-compose.yml
File metadata and controls
316 lines (304 loc) · 9.27 KB
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
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
version: '3'
services:
#-----------------------------------------------
# Web Services
#-----------------------------------------------
# caddy:
# image: caddy:2.8.4
# env_file: .env
# environment:
# - ACME_AGREE=true
# volumes:
# - ./Caddyfile:/etc/caddy/Caddyfile
# - ./src/staticfiles:/var/www/django/static
# - ./caddy_data:/data
# - ./caddy_config:/config
# - ./var/log/caddy:/var/log/
# restart: unless-stopped
# ports:
# - 80:80
# - 443:443
# depends_on:
# - django
# networks:
# custom_network:
django:
build:
context: .
network: host
args:
HTTP_PROXY: ${HTTP_PROXY:-http://127.0.0.1:7890}
HTTPS_PROXY: ${HTTPS_PROXY:-http://127.0.0.1:7890}
# NOTE: We use watchmedo to reload gunicorn nicely, Uvicorn + Gunicorn reloads don't work well
command: bash -c "python manage.py collectstatic --noinput && cd /app/src && watchmedo auto-restart -p '*.py' --recursive -- gunicorn asgi:application -w 2 -k uvicorn.workers.UvicornWorker -b :8000 -b :80 --capture-output --log-level debug"
environment:
- DATABASE_URL=postgres://${DB_USERNAME}:${DB_PASSWORD}@${DB_HOST}:${DB_PORT}/${DB_NAME}
- TZ=Asia/Shanghai
env_file: .env
volumes:
- .:/app:delegated
- /tmp/codalab-v2/django:/codalab_tmp
- ./backups:/app/backups
- ./var/logs:/app/logs
restart: unless-stopped
ports:
- 8000:8000
depends_on:
- db
- rabbit
- minio
stdin_open: true
tty: true
logging:
options:
max-size: "20m"
max-file: "5"
networks:
custom_network:
#-----------------------------------------------
# Minio local storage helper
#-----------------------------------------------
minio:
image: minio/minio:RELEASE.2020-10-03T02-19-42Z
command: server /export
volumes:
- ./var/minio:/export
- /etc/localtime:/etc/localtime:ro
- /usr/share/zoneinfo/Asia/Shanghai:/etc/timezone:ro
environment:
- TZ=Asia/Shanghai
restart: unless-stopped
ports:
- $MINIO_PORT:9000
env_file: .env
healthcheck:
test: [ "CMD", "nc", "-z", "minio", "9000" ]
interval: 5s
retries: 5
networks:
custom_network:
createbuckets:
image: minio/mc
depends_on:
minio:
condition: service_healthy
env_file: .env
environment:
- TZ=Asia/Shanghai
volumes:
- /etc/localtime:/etc/localtime:ro
- /usr/share/zoneinfo/Asia/Shanghai:/etc/timezone:ro
entrypoint: >
/bin/sh -c " set -x; if [ -n \"$MINIO_ACCESS_KEY\" ] && [ -n \"$MINIO_SECRET_KEY\" ] && [ -n \"$MINIO_PORT\" ]; then
until /usr/bin/mc config host add minio_docker http://minio:$MINIO_PORT $MINIO_ACCESS_KEY $MINIO_SECRET_KEY && break; do
echo '...waiting...' && sleep 5;
done;
/usr/bin/mc mb minio_docker/$AWS_STORAGE_BUCKET_NAME || echo 'Bucket $AWS_STORAGE_BUCKET_NAME already exists.';
/usr/bin/mc mb minio_docker/$AWS_STORAGE_PRIVATE_BUCKET_NAME || echo 'Bucket $AWS_STORAGE_PRIVATE_BUCKET_NAME already exists.';
/usr/bin/mc anonymous set download minio_docker/$AWS_STORAGE_BUCKET_NAME;
else
echo 'MINIO_ACCESS_KEY, MINIO_SECRET_KEY, or MINIO_PORT are not defined. Skipping buckets creation.';
fi; exit 0; "
networks:
custom_network:
#-----------------------------------------------
# Local development helper, rebuilds RiotJS/Stylus on change
#-----------------------------------------------
builder:
build:
context: .
dockerfile: Dockerfile.builder
network: host
args:
HTTP_PROXY: ${HTTP_PROXY:-http://127.0.0.1:7890}
HTTPS_PROXY: ${HTTPS_PROXY:-http://127.0.0.1:7890}
volumes:
- .:/app:delegated
- /etc/localtime:/etc/localtime:ro
- /usr/share/zoneinfo/Asia/Shanghai:/etc/timezone:ro
environment:
- TZ=Asia/Shanghai
restart: unless-stopped
logging:
options:
max-size: "20m"
max-file: "5"
networks:
custom_network:
#-----------------------------------------------
# Database Service
#-----------------------------------------------
db:
image: postgres:12-alpine
env_file: .env
environment:
- PGDATA=/var/lib/postgresql/data/pgdata
- POSTGRES_PASSWORD=${DB_PASSWORD}
- TZ=Asia/Shanghai
volumes:
- /etc/localtime:/etc/localtime:ro
- /usr/share/zoneinfo/Asia/Shanghai:/etc/timezone:ro
- ./var/postgres:/var/lib/postgresql/data:delegated
- ./backups:/app/backups
command: [ "postgres", "-c", "log_statement=all", "-c", "log_destination=stderr", "-c", "timezone=Asia/Shanghai" ]
ports:
- 5432:5432
restart: unless-stopped
logging:
options:
max-size: "20m"
max-file: "5"
networks:
custom_network:
#-----------------------------------------------
# Rabbitmq & Flower monitoring tool
#-----------------------------------------------
rabbit:
build:
context: .
dockerfile: Dockerfile.rabbitmq
network: host
args:
- WORKER_CONNECTION_TIMEOUT=${WORKER_CONNECTION_TIMEOUT}
- HTTP_PROXY=${HTTP_PROXY:-http://127.0.0.1:7890}
- HTTPS_PROXY=${HTTPS_PROXY:-http://127.0.0.1:7890}
# setting hostname here makes data persist properly between
# containers being destroyed..!
hostname: rabbit
env_file: .env
environment:
- http_proxy=${RABBITMQ_HTTP_PROXY}
- https_proxy=${RABBITMQ_HTTPS_PROXY}
- no_proxy=${RABBITMQ_NO_PROXY}
- TZ=Asia/Shanghai
volumes:
- /etc/localtime:/etc/localtime:ro
- /usr/share/zoneinfo/Asia/Shanghai:/etc/timezone:ro
- ./var/rabbit:/var/lib/rabbitmq
ports:
- ${RABBITMQ_MANAGEMENT_PORT:-15672}:15672
- ${RABBITMQ_PORT}:5672
restart: unless-stopped
logging:
options:
max-size: "20m"
max-file: "5"
networks:
custom_network:
flower:
build:
context: .
dockerfile: Dockerfile.flower
network: host
args:
- HTTP_PROXY=${HTTP_PROXY:-http://127.0.0.1:7890}
- HTTPS_PROXY=${HTTPS_PROXY:-http://127.0.0.1:7890}
env_file: .env
environment:
- CELERY_BROKER_URL=pyamqp://${RABBITMQ_DEFAULT_USER}:${RABBITMQ_DEFAULT_PASS}@${RABBITMQ_HOST}:${RABBITMQ_PORT}//
- TZ=Asia/Shanghai
volumes:
- /etc/localtime:/etc/localtime:ro
- /usr/share/zoneinfo/Asia/Shanghai:/etc/timezone:ro
restart: unless-stopped
ports:
- ${FLOWER_PUBLIC_PORT:-5555}:5555
depends_on:
- rabbit
logging:
options:
max-size: "20m"
max-file: "5"
networks:
custom_network:
#-----------------------------------------------
# Redis
#-----------------------------------------------
redis:
image: redis
ports:
- 6379:6379
environment:
- TZ=Asia/Shanghai
volumes:
- /etc/localtime:/etc/localtime:ro
- /usr/share/zoneinfo/Asia/Shanghai:/etc/timezone:ro
restart: unless-stopped
logging:
options:
max-size: "20m"
max-file: "5"
networks:
custom_network:
#-----------------------------------------------
# Celery Service
#-----------------------------------------------
site_worker:
# This auto-reloads
command: bash -c "watchmedo auto-restart -p '*.py' --recursive -- celery -A celery_config worker -B -Q site-worker -l info -n site-worker@%n --concurrency=2"
working_dir: /app/src
build:
context: .
network: host
args:
- HTTP_PROXY=${HTTP_PROXY:-http://127.0.0.1:7890}
- HTTPS_PROXY=${HTTPS_PROXY:-http://127.0.0.1:7890}
depends_on:
- rabbit
- db
env_file: .env
environment:
- TZ=Asia/Shanghai
volumes:
- .:/app
- /etc/localtime:/etc/localtime:ro
- /usr/share/zoneinfo/Asia/Shanghai:/etc/timezone:ro
restart: unless-stopped
logging:
options:
max-size: "20m"
max-file: "5"
deploy:
resources:
limits:
# Limit memory substantially here so we see any problems that may
# appear on Heroku ahead of time
memory: 256M
networks:
custom_network:
compute_worker:
command: bash -c "watchmedo auto-restart -p '*.py' --recursive -- celery -A compute_worker worker -l info -Q compute-worker -n compute-worker@%n"
working_dir: /app
build:
context: .
dockerfile: Dockerfile.compute_worker
network: host
args:
- HTTP_PROXY=${HTTP_PROXY:-http://127.0.0.1:7890}
- HTTPS_PROXY=${HTTPS_PROXY:-http://127.0.0.1:7890}
depends_on:
- django
- rabbit
volumes:
- ./compute_worker:/app
- ${HOST_DIRECTORY:-/tmp/codabench}:/codabench
- /var/run/docker.sock:/var/run/docker.sock
- /etc/localtime:/etc/localtime:ro
- /usr/share/zoneinfo/Asia/Shanghai:/etc/timezone:ro
env_file: .env
environment:
- BROKER_URL=pyamqp://${RABBITMQ_DEFAULT_USER}:${RABBITMQ_DEFAULT_PASS}@${RABBITMQ_HOST}:${RABBITMQ_PORT}//
- CODALAB_IGNORE_CLEANUP_STEP=1
- TZ=Asia/Shanghai
logging:
options:
max-size: "20m"
max-file: "5"
networks:
custom_network:
networks:
custom_network:
driver: bridge
ipam:
config:
- subnet: 192.168.100.0/24