-
Notifications
You must be signed in to change notification settings - Fork 130
/
build.sh
executable file
·122 lines (99 loc) · 2.62 KB
/
build.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/bin/sh
reset=$(tput sgr0)
green=$(tput setaf 76)
blue=$(tput setaf 25)
red=$(tput setaf 1)
info() {
printf "${blue}➜ %s${reset}\n" "$@"
}
error() {
printf "${red}➜ %s${reset}\n" "$@"
}
success() {
printf "${green}✔ %s${reset}\n" "$@"
}
checkImage(){
images=$(docker images|grep "$1"|awk '{print $2}')
if [[ -z "$images" ]];then
success "image $1:$2 build fail,do not exists"
exit 1
fi
for image in $images
do
#echo $image
if [[ "$2" == "$image" ]];then
info "build docker image for $DIR SUCCESS..."
return
fi
done
success "image $1:$2 build fail,does not exists"
exit 1
}
info "welcome! "
info "attention: docker 1.10.0+ and docker-compose 1.6.0+"
info "attention: install path Disk capacity is large enough"
echo "";
###check docker and docker-compose
command -v docker >/dev/null 2>&1 || { error "Opendcp require docker but it's not installed. "; error "Please refer to https://docs.docker.com/ or https://docs.docker.com/engine/installation/linux/"; error "Aborting."; exit 1; }
command -v docker-compose >/dev/null 2>&1 || { error "Opendcp require docker-compose but it's not installed. Aborting."; error "Please refer to https://docs.docker.com/compose/install/"; error "Aborting."; exit 1; }
if [[ $# < 1 ]] ; then
success "USAGE: $0 CLOUD TAG "
success "e.g.: $0 aliyun"
success "e.g.: $0 aliyun latest"
exit 1;
fi
if [[ "aliyun" != "$1" && "dockerio" != "$1" ]] ;then
success "SUPPORT CLOUD: dockerio , aliyun !"
exit 1;
fi
DIRS="orion jupiter octans db_init proxy hubble ui imagebuild"
REG=weibo.com
LOC=opendcp
VER=latest
CLOUD=$1
if [ "" != "$2" ] ;then
VER=$2
fi
fail=0
for DIR in $DIRS; do
cd $DIR
TAG=${REG}/${LOC}/${DIR}:${VER}
info "build docker image for $DIR ..."
info "tag is $TAG"
if [ "$CLOUD" = "aliyun" ]; then
\cp -f Dockerfile_Aliyun Dockerfile
fi
if [ "$CLOUD" = "dockerio" ]; then
\cp -f Dockerfile_Dockerio Dockerfile
fi
if [ "$DIR" = "imagebuild" ]; then
./build.sh $CLOUD $TAG
else
./build.sh $TAG
fi
if [[ 0 != $? ]] ; then
info "FAIL"
fail=1
break
fi
#echo "push docker image for $DIR ..."
#docker push $TAG
if [[ 0 != $? ]] ; then
echo "FAIL"
fail=1
break
fi
cd ..
success "$DIR OK"
checkImage ${REG}/${LOC}/${DIR} ${VER}
done
if [[ $fail == 1 ]]; then
exit 1
fi
currentDir=$(cd $(dirname $0) && ( pwd ))
sed -i "s/VER=.*/VER=${VER}/g" $currentDir/deploy/run.sh
if [[ 0 != $? ]] ; then
info "FAIL update run.sh"
exit 1
fi
echo "ALL DONE"