-
Notifications
You must be signed in to change notification settings - Fork 6
/
manage.sh
executable file
·61 lines (50 loc) · 1.21 KB
/
manage.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
#!/usr/bin/env bash
REV=`git rev-parse --short HEAD`
IMGNAME="uxbox"
function kill_container {
if $(sudo docker ps |grep -q $IMGNAME); then
sudo docker ps |grep $IMGNAME | awk '{print $1}' | xargs --no-run-if-empty sudo docker kill
fi
}
function build_image {
kill_container
sudo docker build --rm=true -t $IMGNAME:$REV docker/
}
function initialize {
if [ ! -e ./uxbox ]; then
git clone [email protected]:uxbox/uxbox.git
fi
if [ ! -e ./uxbox-backend ]; then
git clone [email protected]:uxbox/uxbox-backend.git
fi
}
function run_image {
kill_container
initialize
if ! $(sudo docker images|grep $IMGNAME |grep -q $REV); then
build_image
fi
sudo docker run -ti \
-v `pwd`/uxbox:/home/uxbox/uxbox \
-v `pwd`/uxbox-backend:/home/uxbox/uxbox-backend \
-v $HOME/.m2:/home/uxbox/.m2 \
-v $HOME/.gitconfig:/home/uxbox/.gitconfig \
-p 3449:3449 -p 6060:6060 -p 9090:9090 $IMGNAME:$REV
}
function usage {
echo "USAGE: $0 [ build | run | init ]"
}
case $1 in
build)
build_image
;;
run)
run_image
;;
init)
initialize
;;
*)
usage
;;
esac