-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathdocker-compose.yaml
126 lines (126 loc) · 4.11 KB
/
docker-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
# MYSQL_VER=8.0 docker compose up -d
version: "2.4"
services:
db:
image: datajoint/mysql:${MYSQL_VER}
environment:
- MYSQL_ROOT_PASSWORD=${PHARUS_PASSWORD}
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
timeout: 30s
retries: 5
interval: 15s
pharus:
depends_on:
db:
condition: service_healthy
fakeservices.datajoint.io:
condition: service_healthy
image: datajoint/pharus:0.8.0
environment:
- PHARUS_SPEC_PATH=/main/specs/sciviz_spec.yaml # SciViz spec file location
- PHARUS_HOST
- PHARUS_USER
- PHARUS_PASSWORD
volumes:
- ./sciviz_spec.yaml:/main/specs/sciviz_spec.yaml # mount SciViz spec file
- ./initialize.ipynb:/main/initialize.ipynb # initialize test pipeline
- ./pip_requirements.txt:/tmp/pip_requirements.txt # dependencies for test pipeline
command:
- sh
- -c
- |
set -e
# initialize test data
ipython --TerminalIPythonApp.file_to_run=initialize.ipynb
# live reload
pharus_update() {
sleep 2 # delaying to ensure pharus is up
[ -z "$$PRIMARY_PID" ] || kill $$PRIMARY_PID || echo "restarting"
export DEBUG=1
export FLASK_ENV=development
pharus &
PRIMARY_PID=$$!
}
pharus_update
echo "[$$(date -u '+%Y-%m-%d %H:%M:%S')][DataJoint]: Monitoring Pharus updates..."
INIT_TIME=$$(date +%s)
LAST_MOD_TIME=$$(date -r $$PHARUS_SPEC_PATH +%s)
DELTA=$$(expr $$LAST_MOD_TIME - $$INIT_TIME)
while true; do
CURR_LAST_MOD_TIME=$$(date -r $$PHARUS_SPEC_PATH +%s)
CURR_DELTA=$$(expr $$CURR_LAST_MOD_TIME - $$INIT_TIME)
if [ "$$DELTA" -lt "$$CURR_DELTA" ]; then
echo "[$$(date -u '+%Y-%m-%d %H:%M:%S')][DataJoint]: Reloading Pharus since \`$$DJSCIVIZ_SPEC_PATH\` changed."
pharus_update
DELTA=$$CURR_DELTA
else
sleep 1
fi
done
sci-viz:
image: datajoint/sci-viz:1.1.0
environment:
- REACT_APP_DJSCIVIZ_BACKEND_PREFIX=/api # Pharus API prefix
- DJSCIVIZ_SPEC_PATH=sciviz_spec.yaml # SciViz spec file location
- NODE_OPTIONS="--max-old-space-size=4000" # increase build memory for larger apps
volumes:
- ./sciviz_spec.yaml:/main/sciviz_spec.yaml # mount SciViz spec file
command:
- sh
- -c
- |
set -e
# live reload
sciviz_update() {
sleep 3 # delaying to ensure pharus is up
[ -z "$$PRIMARY_PID" ] || kill $$PRIMARY_PID || echo "restarting"
python frontend_gen.py
yarn run start &
PRIMARY_PID=$$!
}
sciviz_update
echo "[$$(date -u '+%Y-%m-%d %H:%M:%S')][DataJoint]: Monitoring SciViz updates..."
INIT_TIME=$$(date +%s)
LAST_MOD_TIME=$$(date -r $$DJSCIVIZ_SPEC_PATH +%s)
DELTA=$$(expr $$LAST_MOD_TIME - $$INIT_TIME)
while true; do
CURR_LAST_MOD_TIME=$$(date -r $$DJSCIVIZ_SPEC_PATH +%s)
CURR_DELTA=$$(expr $$CURR_LAST_MOD_TIME - $$INIT_TIME)
if [ "$$DELTA" -lt "$$CURR_DELTA" ]; then
echo "[$$(date -u '+%Y-%m-%d %H:%M:%S')][DataJoint]: Reloading SciViz since \`$$DJSCIVIZ_SPEC_PATH\` changed."
sciviz_update
DELTA=$$CURR_DELTA
else
sleep 2
fi
done
healthcheck:
test:
[
"CMD",
"wget",
"--no-verbose",
"--tries=1",
"--spider",
"http://localhost:3000",
]
timeout: 30s
retries: 10
interval: 15s
fakeservices.datajoint.io:
image: datajoint/nginx:v0.2.4
environment:
- ADD_db_TYPE=DATABASE
- ADD_db_ENDPOINT=db:3306
- ADD_pharus_TYPE=REST
- ADD_pharus_ENDPOINT=pharus:5000
- ADD_pharus_PREFIX=/api
- ADD_sciviz_TYPE=REST
- ADD_sciviz_ENDPOINT=sci-viz:3000
- ADD_sciviz_PREFIX=/
- HTTPS_PASSTHRU=TRUE
ports:
- "443:443"
- "80:80"
- "3306:3306"