-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild
executable file
·78 lines (65 loc) · 1.59 KB
/
build
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
#!/bin/bash
usage() {
me=`basename "$0"`
echo >&2 "Usage: $me [--tag TAG] [--gerrit-url URL] [IMAGE]"
exit 1
}
while test $# -gt 0 ; do
case "$1" in
--tag)
shift
TAG=$1
shift
;;
--gerrit-url)
shift
GERRIT_WAR_URL=$1
shift
;;
*)
break
esac
done
GIT_REV=$(git describe --dirty)
test -z "$TAG" && TAG=latest
docker_build(){
IMAGE=$1
docker build -t k8sgerrit/$IMAGE:$TAG -t k8sgerrit/$IMAGE:$GIT_REV ./container-images/$IMAGE && BUILD_SUCCESS=1
if test -z "$BUILD_SUCCESS"; then
REPORT="$REPORT Failed: k8sgerrit/$IMAGE.\n"
RETURN_CODE=1
else
REPORT="$REPORT Success: k8sgerrit/$IMAGE:$TAG\n Success: k8sgerrit/$IMAGE:$GIT_REV\n"
fi
}
docker_build_gerrit_base(){
if test -n "$GERRIT_WAR_URL"; then
BUILD_ARGS="--build-arg GERRIT_WAR_URL=$GERRIT_WAR_URL"
fi
docker build $BUILD_ARGS -t gerrit-base ./container-images/gerrit-base || {
echo -e "\n\nFailed to build gerrit-base image."
exit 1
}
}
REPORT="Build results: \n"
RETURN_CODE=0
docker build -t base ./container-images/base || {
echo -e "\n\nFailed to build base image."
exit 1
}
if test $# -eq 0 ; then
docker_build_gerrit_base
for IMAGE in apache-git-http-backend gerrit-master gerrit-slave git-gc mysql-replication-init gerrit-init; do
docker_build $IMAGE
done
else
while test $# -gt 0 ; do
if [[ $1 = gerrit-* ]]; then
docker_build_gerrit_base
fi
docker_build $1
shift
done
fi
echo -e "\n\n$REPORT"
exit $RETURN_CODE