-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuildnrun.sh
executable file
·52 lines (41 loc) · 1.06 KB
/
buildnrun.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
#!/bin/bash
#########################################
# Build and run docker image #
# 02/18 Y. Behr <[email protected]> #
#########################################
RUNONLY=false
BUILDONLY=false
function usage(){
cat <<EOF
Usage: $0 [Options]
Build and run docker image.
Options:
-h Show this message.
-r Only run image without rebuilding it.
-b Only rebuild image without running it.
-t Assign a tag to the docker image (default: latest).
EOF
}
TAG="latest"
# Processing command line options
while [ $# -gt 0 ]
do
case "$1" in
-r) RUNONLY=true;;
-b) BUILDONLY=true;;
-t) TAG=$2;shift;;
-h) usage; exit 0;;
-*) usage; exit 1;;
*) break;;
esac
shift
done
if [ "${RUNONLY}" == "false" ]; then
docker rmi yadabe/rs:$TAG
docker build --no-cache=true -t yadabe/rs:$TAG .
fi
if [ "${BUILDONLY}" == "false" ] ;then
docker stop rs
docker rm rs
docker run --restart="unless-stopped" --name rs -p 3000:3000 -d yadabe/rs:$TAG
fi