Support using OS other than Debian as base for custom images

Signed-off-by: Balasankar "Balu" C <balasankar@gitlab.com>
This commit is contained in:
Balasankar "Balu" C 2022-06-15 09:51:03 +05:30
parent 703c30315e
commit 0dea43ac3b
No known key found for this signature in database
GPG key ID: B77D2E2E23735427
14 changed files with 345 additions and 226 deletions

View file

@ -3,27 +3,28 @@
set -xeuo pipefail
IFS=$'\n\t'
if [[ $(dpkg --print-architecture) == arm64 ]]; then
echo "The arm64 does not have prebuilt chrome. Using chromium instead."
function build_debian() {
if [[ $(dpkg --print-architecture) == arm64 ]]; then
echo "The arm64 does not have prebuilt chrome. Using chromium instead."
apt-get update -q -y
apt-get install -y chromium chromium-driver
apt-get autoremove -yq
apt-get clean -yqq
rm -rf /var/lib/apt/lists/*
exit 0
fi
CHROME_VERSION=${1:-99.0.4844.74-1}
CHROME_DRIVER_VERSION=${2:-99.0.4844.51}
# We hard code the URL rather than using $CI_API_V4_URL $CI_PROJECT_ID,
# because we would need to forward those variables
CHROME_DOWNLOAD_URL_BASE="https://gitlab.com/api/v4/projects/1075790/packages/generic/google-chrome-stable"
export DEBIAN_FRONTEND=noninteractive
curl -sS -L https://dl.google.com/linux/linux_signing_key.pub | apt-key add -
echo "deb http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google.list
apt-get update -q -y
apt-get install -y chromium chromium-driver
apt-get autoremove -yq
apt-get clean -yqq
rm -rf /var/lib/apt/lists/*
exit 0
fi
CHROME_VERSION=${1:-99.0.4844.74-1}
CHROME_DRIVER_VERSION=${2:-99.0.4844.51}
# We hard code the URL rather than using $CI_API_V4_URL $CI_PROJECT_ID,
# because we would need to forward those variables
CHROME_DOWNLOAD_URL_BASE="https://gitlab.com/api/v4/projects/1075790/packages/generic/google-chrome-stable"
export DEBIAN_FRONTEND=noninteractive
curl -sS -L https://dl.google.com/linux/linux_signing_key.pub | apt-key add -
echo "deb http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google.list
apt-get update -q -y
# Download from our package registry if we can't find the package in the apt repository
echo "Searching for $CHROME_VERSION in apt repository"
@ -55,3 +56,12 @@ apt-get autoremove -yq
apt-get clean -yqq
rm -rf /var/lib/apt/lists/*
rm -rf /etc/apt/sources.list.d/google*.list
}
BUILD_OS=${BUILD_OS:-debian}
if [[ $BUILD_OS =~ debian ]]; then
build_debian "$@"
elif [[ $BUILD_OS =~ ubi ]]; then
build_ubi "$@"
fi