-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-compose.yml
111 lines (105 loc) · 3.2 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
version: '3.8'
services:
db-setup:
image: biodb
build:
context: .
dockerfile: Dockerfile
container_name: biodb-db-initializer
restart: "no"
volumes:
- db-data:/app/db
- arraydata-files:/app/array_data
- bulk-upload-files:/app/raw_data
- spectaldata-files:/app/datasets
environment:
DJANGO_SETTINGS_MODULE: biodb.settings.prd
secrets:
- superuser_password
- django_secret_key
command: >
bash -c "set -e
[ ! -f /app/db/setup_complete.txt ]
&& export SECRET_KEY=$(cat /run/secrets/django_secret_key)
&& python manage.py makemigrations user
&& python manage.py makemigrations uploader
&& python manage.py makemigrations catalog
&& python manage.py migrate
&& python manage.py migrate --database=bsr
&& python manage.py loaddata centers queries
&& python manage.py loaddata --database=bsr centers observables instruments qcannotators biosampletypes arraymeasurementtypes
&& python manage.py update_sql_views flat_view
&& python manage.py crontab add
&& python manage.py prune_files
&& DJANGO_SUPERUSER_PASSWORD=$(cat /run/secrets/superuser_password) python manage.py createsuperuser --noinput --username=admin --email=admin@jhu.org --center=16721944-ff91-4adf-8fb3-323b99aba801
&& touch /app/db/setup_complete.txt || echo done!"
web:
depends_on:
db-setup:
condition: service_completed_successfully
image: biodb
deploy:
mode: global
restart_policy:
condition: on-failure
delay: 5s
max_attempts: 3
window: 60s
expose:
- 8000
volumes:
- db-data:/app/db
- arraydata-files:/app/array_data
- bulk-upload-files:/app/raw_data
- dataset-catalog-files:/app/datasets
- static_files:/app/static
environment:
DJANGO_SETTINGS_MODULE: biodb.settings.prd
secrets:
- django_secret_key
- email_api_key
command: >
bash -c "mkdir -p log
&& mkdir -p run
&& SECRET_KEY=$(cat /run/secrets/django_secret_key) python manage.py collectstatic --clear --noinput
&& SECRET_KEY=$(cat /run/secrets/django_secret_key) EMAIL_API_KEY=$(cat /run/secrets/email_api_key) gunicorn -c config/gunicorn/prd.py"
healthcheck:
test: ["CMD-SHELL", "curl --head --fail --header 'X-Forwarded-Proto: https' http://localhost:8000/healthz/ || exit 1"]
interval: 60s
timeout: 10s
retries: 3
start_period: 60s
nginx:
build: ./nginx
deploy:
mode: global
restart_policy:
condition: on-failure
delay: 5s
max_attempts: 3
window: 10s
container_name: biodb-nginx
ports:
- "80:80"
- "443:443"
volumes:
- static_files:/static
- arraydata-files:/array_data
- bulk-upload-files:/raw_data
- dataset-catalog-files:/datasets
depends_on:
web:
condition: service_healthy
secrets:
superuser_password:
environment: DJANGO_SUPERUSER_PASSWORD
django_secret_key:
environment: SECRET_KEY
email_api_key:
environment: EMAIL_API_KEY
volumes:
db-data:
arraydata-files:
bulk-upload-files:
dataset-catalog-files:
static_files: