Repository navigation
Expand file tree
/
Copy pathcli
More file actions
executable file
·81 lines (73 loc) · 1.74 KB
/
Copy pathcli
File metadata and controls
executable file
·81 lines (73 loc) · 1.74 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
#!/usr/bin/env bash
BRANCH="$(echo $( git rev-parse --abbrev-ref HEAD) | tr '[:upper:]' '[:lower:]')"
DOCKER_IMAGE="sad_final_project:${BRANCH}"
declare -a valid_arguments=( "build" "start" "enter" "jupyter" "stop" )
[[ $valid_arguments =~ (^|[[:space:]])$1($|[[:space:]]) ]] \
&& echo 'yes' || echo 'Must be one of the following arguments: build, start, enter, jupyter, stop'
if [ $# -gt 1 ]
then
echo 'Only takes one argument'
exit 1
fi
# build docker image
if [ $1 == 'build' ]
then
docker build -t ${DOCKER_IMAGE} .
exit 0
fi
# start Docker session
# mount repo into home directory
# port forward for Jupyter notebook
# store container ID in text file
if [ $1 == 'start' ]
then
echo 'Starting Docker container'
docker run -itd \
-v $(pwd):/root/ \
-p 8889:8888 \
${DOCKER_IMAGE} \
> docker_id.txt
cat docker_id.txt
exit 0
fi
# start Docker session
# mount repo into home directory
# port forward for Jupyter notebook
# store container ID in text file
if [ $1 == 'start_prince' ]
then
echo 'Starting Docker container'
docker run -itd \
-v $(pwd):/root/ \
-v /scratch/work/js11133/sad_data/:/root/data/ \
-p 8889:8888 \
${DOCKER_IMAGE} \
> docker_id.txt
cat docker_id.txt
exit 0
fi
# enter running Docker session with interactive shell
# using text file
if [ $1 == 'enter' ]
then
docker exec -it $(cat docker_id.txt) /bin/bash
exit 0
fi
# start Jupyter notebook in Docker
if [ $1 == 'jupyter' ]
then
echo 'Navigate to localhost:8889 to access the Jupyter notebook'
docker exec -it $(cat docker_id.txt) jupyter-notebook \
--ip 0.0.0.0 \
--no-browser \
--allow-root \
--NotebookApp.token='' \
--NotebookApp.password=''
exit 0
fi
if [ $1 == 'stop' ]
then
docker stop $(cat docker_id.txt)
rm docker_id.txt
exit 0
fi