-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild
More file actions
executable file
·145 lines (133 loc) · 4.59 KB
/
build
File metadata and controls
executable file
·145 lines (133 loc) · 4.59 KB
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#!/bin/bash
PROGNAME=`basename "$0"`
function usage {
echo "./${PROGNAME} [-x <xrootd-version>] [-e <eos-version>] [-q <qdb-version>] [-i <list,of,images>] [-t <tag>] [-c] [-g] [-p] [-f] [-h]"
echo " -x specify xrootd version, defaults to latest known stable"
echo " -e specify eos version, defaults to latest known stable"
echo " -q specify quarkdb version, defaults to latest known stable"
echo " -i specify target images to build"
echo " -t specify tag for built images"
echo " -c compile from dss/eos repo instead of installing eos from rpm - modify Dockertmp.compile to change source repo"
echo " -p push images to repo after building"
echo " -f force a fresh build instead of using cache"
echo " -h prints this thing i guess"
exit 0
}
set_base () {
if [ -z "$1" ] || ! [ -f "containers/Dockertmp.$1" ] ; then
echo "Tried to set base image for invalid Dockerfile"
return 1
fi
sed "s|BASE_IMAGE|${base_image}|g" containers/Dockertmp.$1 > containers/Dockerfile.$1
}
# check which options are set
while getopts "x:e:q:i:t:gcpfh" opt; do
case "$opt" in
x) xrd_version=${OPTARG} ;;
e) eos_version=${OPTARG} ;;
q) qdb_version=${OPTARG} ;;
i) targets=${OPTARG} ;;
t) tag=${OPTARG} ;;
c) compile=true ;;
p) push=true ;;
f) force="--no-cache" ;;
h) usage ;;
\?) usage ;;
esac
done
# set our build variables
export base_image='centos:7'
export registry=''
export project='cloudservices/eos/'
export qdb_version=${qdb_version:-0.4.0}
export eos_version=${eos_version:-4.6.5}
if [[ $eos_version = 4.4.* ]]; then
export xrd_version=4.8.6
else
export xrd_version=${xrd_version:-4.11.0}
fi
if ! [ -v tag ]; then
export tag=${eos_version:-test}
fi
# check which containers to build
export min="mq mgm fst eosd eosxd qdb"
export all="${min} monitor sync eossync qdbackup"
if ! [ -v targets ]; then
export targets=${min}
else
if [[ ${targets} = *all* ]]; then
export targets=${all}
else
export targets=$(echo ${targets} | sed 's/,/ /g')
fi
fi
export standalone=""
export dependencies=""
for image in ${targets}; do
case "${image}" in
mq|mgm|fst|qdb|qdbackup|sync|eossync|monitor)
if [ -z "$dependencies" ]; then
dependencies="${image}"
else
dependencies="${dependencies} ${image}"
fi
;;
eosd|eosxd)
if [ -z "$standalone" ]; then
standalone="${image}"
else
standalone="${standalone} ${image}"
fi
;;
*)
echo "invalid image option ${image} - must be one of ${all}"
esac
done
# build standalone containers, if any
if ! [ -z "$standalone" ]; then
for target in ${standalone}; do
set_base ${target}
sudo docker build ${force} --build-arg EOS_VERSION=${eos_version} --build-arg XRD_VERSION=${xrd_version} --file containers/Dockerfile.${target} -t ${registry}${project}eos-citrine-${target}:${tag} .
if [ -v push ]; then
sudo docker login ${registry}
sudo docker push ${registry}${project}eos-citrine-${target}:${tag}
fi
done
fi
# build containers that require eos/base, if any
if ! [ -z "$dependencies" ]; then
# build eos-base
if [ -v compile ]; then
echo "Building from repository"
set_base compile
sudo docker build ${force} --build-arg XRD_VERSION=${xrd_version} --file containers/Dockerfile.compile -t eos/base:${tag} .
if [ $? -ne 0 ]; then
exit
fi
else
set_base base
sudo docker build ${force} --build-arg EOS_VERSION=${eos_version} --build-arg XRD_VERSION=${xrd_version} --file containers/Dockerfile.base -t eos/base:${tag} .
if [ $? -ne 0 ]; then
exit
fi
fi
for target in ${dependencies}; do
set_base ${dependencies}
sed "s|VERSION_PLACEHOLDER|${tag}|g" containers/Dockertmp.${target} > containers/Dockerfile.${target}
if [[ ${target} = "qdb" ]] || [[ ${target} = "qdbackup" ]]; then
sudo docker build ${force} --build-arg QDB_VERSION=${qdb_version} --build-arg EOS_VERSION=${eos_version} --file containers/Dockerfile.${target} -t ${registry}${project}eos-citrine-${target}:${tag:-$qdb_version} .
if [ -v push ]; then
sudo docker login ${registry}
sudo docker push ${registry}${project}eos-citrine-${target}:${tag:-$qdb_version}
fi
else
sudo docker build ${force} --file containers/Dockerfile.${target} -t ${registry}${project}eos-citrine-${target}:${tag} .
if [ -v push ] && ! [ "$target" = "test" ]; then
sudo docker login ${registry}
sudo docker push ${registry}${project}eos-citrine-${target}:${tag}
fi
fi
done
fi
## delete all generated dockerfiles
rm containers/Dockerfile.*