forked from autorope/donkeycar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
start-server.sh
executable file
·62 lines (54 loc) · 1.9 KB
/
start-server.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
#!/bin/sh
#make directory that will be mounted in the docker instance.
mkdir -p ~/mydonkey/models
mkdir -p ~/mydonkey/datasets
# First check whether the named volume and image exist; if not, build/initialize them.
# Create volume if not already there
HASVOL=$( docker volume ls | grep mydonkey | wc -l )
if [ $HASVOL == 0 ]; then
echo "start-server: Initializing Donkey server volume..." >&2
docker volume create --name mydonkey
fi
HASVOL2=$( docker volume ls | grep donkey | wc -l )
if [ $HASVOL == 0 ]; then
echo "start-server: Initializing Donkey code volume..." >&2
docker volume create --name donkey
fi
# Build if not already built
HASIMAGE=$( docker image ls | grep donkey | wc -l )
if [ $HASIMAGE == 0 ]; then
echo "start-server: Building Donkey server image..." >&2
docker build -t donkey .
fi
# Now check the arguments and accordingly build/initialize/run the server.
while getopts ":vbd" opt; do
case $opt in
v)
if [ $HASVOL == 1 ]; then #means the volume existed, so it was not built
echo "start-server: Initializing Donkey server volume..." >&2
docker volume create --name mydonkey
fi
if [ $HASVOL2 == 1 ]; then #means the volume existed, so it was not built
echo "start-server: Initializing Donkey code volume..." >&2
docker volume create --name donkey
fi
;;
b)
if [ $HASIMAGE == 1 ]; then #means the image existed, so it was not built
echo "start-server: Building Donkey server image..." >&2
docker build -t donkey .
fi
;;
d)
echo "start-server: Running Donkey server container without serve.py and attaching..." >&2
docker run -p 8887:8887 -v ~/mydonkey:/root/mydonkey -v ~/donkey:/donkey --entrypoint=/bin/bash -it donkey
exit
;;
\?)
echo "start-server: Invalid option: -$OPTARG" >&2
exit
;;
esac
done
echo "start-server: Running Donkey server container..." >&2
docker run -p 8887:8887 -v ~/mydonkey:/root/mydonkey -v ~/donkey:/donkey donkey