-
Notifications
You must be signed in to change notification settings - Fork 11
/
update_image
executable file
·60 lines (49 loc) · 2.01 KB
/
update_image
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
#!/bin/bash
# This script builds a docker image that is used for packaging.
#
# This script requires $TARGET_PLATFORM env to contain a supported platform name.
# Sample platform names 'debian,buster', 'centos,7' etc.
# make bash behave
set -euo pipefail
IFS=$'\n\t'
pgversions='11 12 13 14 15 16'
topdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
dockerfiles_dir="${topdir}/dockerfiles"
badusage=64
nprocs="${1:-1}"
declare args
if [ "${TEST}" == "true" ]; then
image_name="packaging-test"
else
image_name="packaging"
fi
IFS=',' read -r os release <<< "${TARGET_PLATFORM}"
if [[ "${os}" = 'debian' ]] || [[ "${os}" = 'ubuntu' ]]; then
tag="${os}-${release}-all"
args+="build --pull --no-cache -t citus/${image_name}:${tag} -f ${dockerfiles_dir}/${tag}/Dockerfile .\n"
elif [[ "${os}" = 'centos' ]] || [[ "${os}" = 'oraclelinux' ]] || [[ "${os}" = 'almalinux' ]]; then
# redhat variants need an image for each PostgreSQL version
IFS=' '
for pgversion in ${pgversions}; do
# if pg_version is given as parameter from TARGET_PLATFORM then match the version and execute for it
if [ -n "${POSTGRES_VERSION}" ] && [ "${pgversion}" != "${POSTGRES_VERSION}" ] ; then
continue
fi
if { [[ "${os}" = 'centos' ]] || [[ "${os}" = 'oraclelinux' ]]; } && \
[[ "${release}" = '6' ]] && [[ "${pgversion}" = '13' ]]; then
# CentOS and OracleLinux 6 doesn't have pg13 packages yet.
# So skip building docker images for them.
continue
fi
pgshort=${pgversion//./}
tag="${os}-${release}-pg${pgshort}"
args+="build --pull --no-cache -t citus/${image_name}:${tag} -f ${dockerfiles_dir}/${tag}/Dockerfile .\n"
done
elif [[ "${os}" = 'pgxn' ]]; then
tag="${os}-all"
args+="build --pull --no-cache -t citus/${image_name}:${tag} -f ${dockerfiles_dir}/${tag}/Dockerfile .\n"
else
echo "$0: unrecognized OS -- ${os}" >&2
exit $badusage
fi
echo -e "${args}" | xargs -t -L1 -P "${nprocs}" docker