mirror of
https://ops.gitlab.net/gitlab-org/gitlab-build-images.git
synced 2025-12-09 10:02:56 +01:00
58 lines
1.7 KiB
Bash
Executable file
58 lines
1.7 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
set -xeuo pipefail
|
|
|
|
DOCKER_VERSION=${1}
|
|
|
|
function build_debian() {
|
|
export DEBIAN_FRONTEND=noninteractive
|
|
DEBIAN_VERSION=$(lsb_release -c -s)
|
|
|
|
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
|
|
|
|
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/*
|
|
}
|
|
|
|
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}
|
|
BUILD_ARCH=${BUILD_ARCH:-amd64}
|
|
|
|
if [[ $BUILD_OS =~ debian ]]; then
|
|
build_debian "$@"
|
|
elif [[ $BUILD_OS =~ ubi ]]; then
|
|
build_ubi "$@"
|
|
fi
|