Support building docker in UBI

Signed-off-by: Balasankar "Balu" C <balasankar@gitlab.com>
This commit is contained in:
Balasankar "Balu" C 2022-07-06 15:39:00 +05:30
parent 523e57a7a5
commit 25a4531f59
No known key found for this signature in database
GPG key ID: B77D2E2E23735427

View file

@ -2,9 +2,10 @@
set -xeuo pipefail
export DEBIAN_FRONTEND=noninteractive
DOCKER_VERSION=${1}
function build_debian() {
export DEBIAN_FRONTEND=noninteractive
DEBIAN_VERSION=$(lsb_release -c -s)
apt-get update
@ -16,7 +17,6 @@ apt-get -y install \
curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add -
echo "deb [arch=amd64] https://download.docker.com/linux/debian ${DEBIAN_VERSION} stable" >> /etc/apt/sources.list.d/docker.list
apt-get update
@ -26,3 +26,32 @@ apt-get install -y docker-ce=${PACKAGE_VERSION} docker-ce-cli=${PACKAGE_VERSION}
apt-get -yq autoremove
apt-get clean -yqq
rm -rf /var/lib/apt/lists/*
}
function build_ubi() {
yum update -y
yum install -y yum-utils
# Docker only provides s390x packages for RHEL. For remaining
# architectures, they recommend using the CentOS repo.
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum update -y
PACKAGE_VERSION=$(yum --showduplicates list docker-ce | awk -v dv=${DOCKER_VERSION} '$2 ~ dv {print $2}')
# Epoch can differ between docker-ce and docker-cli versions.
VERSION_WITHOUT_EPOCH=${PACKAGE_VERSION#*:}
CLI_VERSION=$(yum --showduplicates list docker-ce-cli | awk -v dv=${VERSION_WITHOUT_EPOCH} '$2 ~ dv {print $2}')
yum install -y docker-ce-${PACKAGE_VERSION} docker-ce-cli-${CLI_VERSION}
yum autoremove -y
yum clean -y all
}
BUILD_OS=${BUILD_OS:-debian}
if [[ $BUILD_OS =~ debian ]]; then
build_debian "$@"
elif [[ $BUILD_OS =~ ubi ]]; then
build_ubi "$@"
fi