forked from xwang2713/docker-hpcc-0
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-build.sh
executable file
·114 lines (96 loc) · 2.51 KB
/
test-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
#!/usr/bin/env bash
#
# Run a test build for all images.
source functions
usage()
{
echo ""
echo "Usage: test-build.sh -v <versions list> -p <package list> -l <linux ariant>"
echo " -v major version list, comma delimited"
echo " -p package list, comma delimited. The default is platform."
echo " -l linux variant, comma delimited. The default is Ubuntu. The other choice is centos"
echo ""
exit 1
}
function build()
{
local version
local tag
local variant
local package
local path
version="$1"; shift
package="$1"; shift
variant="$1"; shift
if [ "$variant" = "ubuntu" ]
then
if [ "$package" = "platform" ]
then
tag="latest"
path="$version"
else
full_tag="$package"
path="$version/$package"
fi
else
if [ "$package" = "platform" ]
then
tag=${distro_tag["$variant"]}
path="$version/$package/$variant"
else
tag=${package}-${distro_tag["$variant"]}
path="$version/$package/$variant"
fi
fi
echo
echo
info "Building $tag ..."
info "docker build -t hpcc:$tag $path"
logfile=/tmp/docker_hpcc_${version}_${platform}_${variant}.log
if ! docker build -t "hpcc:$tag" "$path" > $logfile 2>&1
then
fatal "Build of $tag failed!. Log file: $logfile"
else
info "Building succeeded!"
fi
echo ""
info "Testing hpcc:$tag"
if [ "$variant" = "centos" ]
then
info "docker run --rm --privileged -e \"container=docker\" -v \"$PWD/test-${package}.sh:/usr/local/bin/test.sh\" hpcc:${tag} test.sh"
docker run --rm --privileged -e "container=docker" -v "$PWD/test-${package}.sh:/usr/local/bin/test.sh" hpcc:${tag} test.sh
else
info "docker run --rm -v \"$PWD/test-${package}.sh:/usr/local/bin/test.sh\" hpcc:${tag} test.sh"
docker run --rm -v "$PWD/test-${package}.sh:/usr/local/bin/test.sh" hpcc:${tag} test.sh
fi
echo ""
}
versions=("6")
packages=("platform")
variants=("ubuntu")
distro_tag["centos"]="el7"
while getopts "*l:p:v:" arg
do
case "$arg" in
l) IFS=',' read -ra variants <<< "${OPTARG}"
;;
p) IFS=',' read -ra packages <<< "${OPTARG}"
;;
v) IFS=',' read -ra versions <<< "${OPTARG}"
;;
?) usage
;;
esac
done
[ ${#variants[@]} -eq 0 ] && variants=("ubuntu")
[ ${#packages[@]} -eq 0 ] && packages=("platform")
for version in "${versions[@]}"
do
for package in "${packages[@]}"
do
for variant in "${variants[@]}"
do
build "$version" "$package" "$variant"
done
done
done