mirror of
https://ops.gitlab.net/gitlab-org/gitlab-build-images.git
synced 2025-12-09 18:12:55 +01:00
Support building docker in UBI
Signed-off-by: Balasankar "Balu" C <balasankar@gitlab.com>
This commit is contained in:
parent
523e57a7a5
commit
25a4531f59
1 changed files with 46 additions and 17 deletions
|
|
@ -2,27 +2,56 @@
|
|||
|
||||
set -xeuo pipefail
|
||||
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
DOCKER_VERSION=${1}
|
||||
DEBIAN_VERSION=$(lsb_release -c -s)
|
||||
|
||||
apt-get update
|
||||
apt-get -y install \
|
||||
apt-transport-https \
|
||||
ca-certificates \
|
||||
curl \
|
||||
gnupg
|
||||
function build_debian() {
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
DEBIAN_VERSION=$(lsb_release -c -s)
|
||||
|
||||
curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add -
|
||||
apt-get update
|
||||
apt-get -y install \
|
||||
apt-transport-https \
|
||||
ca-certificates \
|
||||
curl \
|
||||
gnupg
|
||||
|
||||
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
|
||||
echo "deb [arch=amd64] https://download.docker.com/linux/debian ${DEBIAN_VERSION} stable" >> /etc/apt/sources.list.d/docker.list
|
||||
apt-get update
|
||||
|
||||
PACKAGE_VERSION=$(apt-cache policy docker-ce | awk -v dv=${DOCKER_VERSION}~ '$1 ~ dv {print $1}')
|
||||
PACKAGE_VERSION=$(apt-cache policy docker-ce | awk -v dv=${DOCKER_VERSION}~ '$1 ~ dv {print $1}')
|
||||
|
||||
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/*
|
||||
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue