-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathvizDocker
executable file
·55 lines (41 loc) · 941 Bytes
/
vizDocker
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
# This shell script shamelessly borrow lot from pocaml:
# https://github.com/Pocaml/Pocaml/blob/main/pocamlc
# Thank you, pocaml team!
#!/usr/bin/env bash
# stop script when a command returns with non-zero
set -e
DOCKER_TAG=viz
DOCKER_WORK_DIR=/home/viz
Usage() {
echo
echo "usage: viz <name_of_file.viz>"
echo
exit 0;
}
Run() {
echo
echo "---"
echo "Building the docker image using Dockerfile, it will take a while..."
docker build -t $DOCKER_TAG .
if [ $? -ne 0 ]; then
echo "docker build failed"
exit;
else
set -e
fi
echo
echo "Done."
echo
echo "---"
echo "Starting the docker container..."
echo
echo
echo ">>> Running in the docker container \"$DOCKER_TAG\" <<<"
docker run --rm -v "$(pwd)":"$DOCKER_WORK_DIR" -w="$DOCKER_WORK_DIR" $DOCKER_TAG /bin/bash -c "./viz $fpath"
echo
}
[ $# -eq 0 ] && Usage
fpath=$1
fname=${fpath##*/}
[[ $fname != *.viz ]] && Usage
Run