forked from angelolab/ark-analysis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
start_docker.sh
executable file
·73 lines (65 loc) · 1.87 KB
/
start_docker.sh
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
#!/usr/bin/env bash
# define the version number, this needs to be updated every new Docker release
VERSION='v0.6.4'
# check for template developer flag
JUPYTER_DIR='scripts'
update=0
external=''
while test $# -gt 0
do
case "$1" in
-n|--develop-notebook-templates)
JUPYTER_DIR='templates'
shift
;;
-u|--update)
update=1
shift
;;
-e|--external)
external="$2"
shift
shift
;;
*)
echo "$1 is not an accepted option..."
echo "-n, --develop-notebook-templates : Mount templates for direct editing."
echo "-u, --update : Update default scripts and code changes"
echo "-e, --external : Mount external drives to /data/external"
exit
;;
esac
done
# update the notebooks in the scripts folder if flag set
if [ $update -ne 0 ]
then
bash update_notebooks.sh -u
else
bash update_notebooks.sh
fi
# find lowest open port available
PORT=8888
until [[ $(netstat -an | grep LISTEN | grep $PORT | wc -l) -eq 0 ]]
do
((PORT=$PORT+1))
done
# define the run parameters
run_params=(
-p $PORT:$PORT
-e JUPYTER_PORT=$PORT
-e JUPYTER_DIR=$JUPYTER_DIR
-e UPDATE_ARK=$update
-v "$PWD/README.md:/opt/ark-analysis/README.md"
-v "$PWD/setup.py:/opt/ark-analysis/setup.py"
-v "$PWD/pyproject.toml:/opt/ark-analysis/pyproject.toml"
-v "$PWD/start_jupyter.sh:/opt/ark-analysis/start_jupyter.sh"
-v "$PWD/src:/opt/ark-analysis/src"
-v "$PWD/scripts:/scripts"
-v "$PWD/data:/data"
-v "$PWD/.git:/opt/ark-analysis/.git"
)
[[ ! -z "$external" ]] && run_params+=(-v "$external:/data/external")
# remove the old Docker container if one exists, as it may contain different external volumes
docker rm -f $VERSION > /dev/null 2>&1 || true
# create the Docker container
docker run -it "${run_params[@]}" --name $VERSION angelolab/ark-analysis:$VERSION