mirror of
https://ops.gitlab.net/gitlab-org/gitlab-build-images.git
synced 2025-12-08 17:42:56 +01:00
Add arm capability without pushing and building images
This commit is contained in:
parent
a467eeb36d
commit
0be7ce1245
16 changed files with 51 additions and 66 deletions
|
|
@ -21,10 +21,7 @@ stages:
|
|||
- automation
|
||||
|
||||
variables:
|
||||
DOCKER_HOST: tcp://docker:2376
|
||||
DOCKER_TLS_CERTDIR: /certs
|
||||
DOCKER_CERT_PATH: /certs/client
|
||||
DOCKER_TLS_VERIFY: 1
|
||||
DOCKER_HOST: tcp://docker:2375
|
||||
|
||||
cache-google-chrome:
|
||||
image: debian:bullseye-slim
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
docker buildx build \
|
||||
--cache-to=type=inline \
|
||||
--cache-from="$CI_REGISTRY_IMAGE:$1" \
|
||||
--platform=linux/${ARCH:-amd64} \
|
||||
--push="${PUSH_CUSTOM_IMAGE:-false}" \
|
||||
--label "ci_pipeline_url=$CI_PIPELINE_URL" \
|
||||
--label "ci_job_url=$CI_JOB_URL" \
|
||||
|
|
|
|||
|
|
@ -1,6 +1,21 @@
|
|||
.build_and_push:
|
||||
stage: custom
|
||||
needs: []
|
||||
tags:
|
||||
- docker
|
||||
- high-cpu
|
||||
variables:
|
||||
QEMU_IMAGE: tonistiigi/binfmt:qemu-v6.2.0
|
||||
timeout: 2 hours
|
||||
before_script:
|
||||
- echo "$CI_REGISTRY_PASSWORD" | docker login "$CI_REGISTRY" -u "$CI_REGISTRY_USER" --password-stdin
|
||||
- |
|
||||
if [ "${ARCH:-amd64}" != "amd64" ]; then
|
||||
echo -e "\033[1;33mInstalling latest qemu emulators\033[0m"
|
||||
docker pull -q ${QEMU_IMAGE};
|
||||
docker run --rm --privileged ${QEMU_IMAGE} --uninstall qemu-*;
|
||||
docker run --rm --privileged ${QEMU_IMAGE} --install all;
|
||||
fi
|
||||
script:
|
||||
- ./scripts/lib/custom-docker-build
|
||||
rules:
|
||||
|
|
|
|||
|
|
@ -22,10 +22,11 @@ e2e-docker:
|
|||
e2e-chrome:
|
||||
extends:
|
||||
- e2e-docker
|
||||
variables:
|
||||
CHROME: '103'
|
||||
parallel:
|
||||
matrix:
|
||||
- RUBY: ['2.7', '3.0']
|
||||
CHROME: ['101', '103']
|
||||
|
||||
# Image used for running full e2e test suite
|
||||
e2e-full:
|
||||
|
|
@ -33,6 +34,5 @@ e2e-full:
|
|||
- e2e-chrome
|
||||
variables:
|
||||
LFS: '2.9'
|
||||
GIT: '2.33'
|
||||
GCLOUD: '383'
|
||||
KUBECTL: '1.23'
|
||||
|
|
|
|||
|
|
@ -7,7 +7,8 @@ ARG CUSTOM_BASE_IMAGE
|
|||
FROM ${CUSTOM_BASE_IMAGE}
|
||||
|
||||
ARG BUILD_OS
|
||||
ARG BUILD_ARCH
|
||||
# TARGETARCH is automatically populated by buildx --platform argument
|
||||
ARG TARGETARCH
|
||||
|
||||
ADD / /
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ set -xeou pipefail
|
|||
BAZELISK_VERSION=${1}
|
||||
BAZELISK_DOWNLOAD_SHA256=${2}
|
||||
|
||||
BAZELISK_DOWNLOAD_URL="https://github.com/bazelbuild/bazelisk/releases/download/v${BAZELISK_VERSION}/bazelisk-linux-amd64"
|
||||
BAZELISK_DOWNLOAD_URL="https://github.com/bazelbuild/bazelisk/releases/download/v${BAZELISK_VERSION}/bazelisk-linux-${TARGETARCH:-amd64}"
|
||||
|
||||
curl -fsSL "$BAZELISK_DOWNLOAD_URL" -o bazelisk
|
||||
echo "${BAZELISK_DOWNLOAD_SHA256} bazelisk" | sha256sum -c -
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ set -xeou pipefail
|
|||
|
||||
BUILDX_VERSION=${1}
|
||||
BUILDX_DOWNLOAD_SHA256=${2}
|
||||
BUILDX_DOWNLOAD_URL="https://github.com/docker/buildx/releases/download/v${BUILDX_VERSION}/buildx-v${BUILDX_VERSION}.linux-$(dpkg --print-architecture)"
|
||||
BUILDX_DOWNLOAD_URL="https://github.com/docker/buildx/releases/download/v${BUILDX_VERSION}/buildx-v${BUILDX_VERSION}.linux-${TARGETARCH:-amd64}"
|
||||
|
||||
curl -fsSL "${BUILDX_DOWNLOAD_URL}" -o docker-buildx
|
||||
echo "${BUILDX_DOWNLOAD_SHA256} docker-buildx" | sha256sum -c -
|
||||
|
|
|
|||
|
|
@ -4,7 +4,9 @@ set -xeuo pipefail
|
|||
IFS=$'\n\t'
|
||||
|
||||
function build_debian() {
|
||||
if [[ $(dpkg --print-architecture) == arm64 ]]; then
|
||||
ARCH="${TARGETARCH:-amd64}"
|
||||
|
||||
if [[ "${ARCH}" == "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
|
||||
|
|
@ -32,7 +34,7 @@ function build_debian() {
|
|||
apt-cache policy google-chrome-stable
|
||||
|
||||
if [[ -z $CHECK_VERSION ]]; then
|
||||
CHROME_DEB="google-chrome-stable_${CHROME_VERSION}_$(dpkg --print-architecture).deb"
|
||||
CHROME_DEB="google-chrome-stable_${CHROME_VERSION}_${ARCH}.deb"
|
||||
CHROME_URL="${CHROME_DOWNLOAD_URL_BASE}/${CHROME_VERSION}/${CHROME_DEB}"
|
||||
echo "Downloading from our Package registry: $CHROME_URL"
|
||||
curl --silent --show-error --fail -O $CHROME_URL
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ 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
|
||||
echo "deb 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}')
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ set -xeou pipefail
|
|||
INSTALL_GOLANG_VERSION=${1}
|
||||
GOLANG_DOWNLOAD_SHA256=${2}
|
||||
|
||||
GOLANG_DOWNLOAD_URL="https://golang.org/dl/go${INSTALL_GOLANG_VERSION}.linux-${BUILD_ARCH}.tar.gz"
|
||||
GOLANG_DOWNLOAD_URL="https://golang.org/dl/go${INSTALL_GOLANG_VERSION}.linux-${TARGETARCH:-amd64}.tar.gz"
|
||||
|
||||
function build_debian() {
|
||||
curl -fsSL "$GOLANG_DOWNLOAD_URL" -o golang.tar.gz
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ set -xeou pipefail
|
|||
|
||||
HELM_VERSION=${1}
|
||||
HELM_DOWNLOAD_SHA256=${2}
|
||||
HELM_DOWNLOAD_URL="https://get.helm.sh/helm-v${HELM_VERSION}-linux-$(dpkg --print-architecture).tar.gz"
|
||||
HELM_DOWNLOAD_URL="https://get.helm.sh/helm-v${HELM_VERSION}-linux-${TARGETARCH:-amd64}.tar.gz"
|
||||
|
||||
curl -fsSL "${HELM_DOWNLOAD_URL}" -o helm.tar.gz
|
||||
echo "${HELM_DOWNLOAD_SHA256} helm.tar.gz" | sha256sum -c -
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ set -xeou pipefail
|
|||
|
||||
KUBECTL_VERSION=${1}
|
||||
KUBECTL_DOWNLOAD_SHA256=${2}
|
||||
KUBECTL_DOWNLOAD_URL="https://dl.k8s.io/release/v${KUBECTL_VERSION}/bin/linux/$(dpkg --print-architecture)/kubectl"
|
||||
KUBECTL_DOWNLOAD_URL="https://dl.k8s.io/release/v${KUBECTL_VERSION}/bin/linux/${TARGETARCH:-amd64}/kubectl"
|
||||
|
||||
curl -fsSL "${KUBECTL_DOWNLOAD_URL}" -o kubectl
|
||||
echo "${KUBECTL_DOWNLOAD_SHA256} kubectl" | sha256sum -c -
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
set -xeuo pipefail
|
||||
IFS=$'\n\t'
|
||||
|
||||
LFS_DOWNLOAD_URL="https://github.com/git-lfs/git-lfs/releases/download/v${LFS_VERSION}/git-lfs-linux-$(dpkg --print-architecture)-v${LFS_VERSION}.tar.gz"
|
||||
LFS_DOWNLOAD_URL="https://github.com/git-lfs/git-lfs/releases/download/v${LFS_VERSION}/git-lfs-linux-${TARGETARCH:-amd64}-v${LFS_VERSION}.tar.gz"
|
||||
|
||||
mkdir build \
|
||||
&& curl -fsSL "$LFS_DOWNLOAD_URL" -o git-lfs.tar.gz \
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ curl -sS -L https://deb.nodesource.com/setup_${NODE_MAJOR} | bash -
|
|||
|
||||
apt-get update
|
||||
|
||||
NODE_FILE_NAME="nodejs_$NODE_INSTALL_VERSION-deb-1nodesource1_$(dpkg --print-architecture).deb"
|
||||
NODE_FILE_NAME="nodejs_$NODE_INSTALL_VERSION-deb-1nodesource1_${TARGETARCH:-amd64}.deb"
|
||||
curl -s -O "https://deb.nodesource.com/node_$NODE_MAJOR/pool/main/n/nodejs/$NODE_FILE_NAME"
|
||||
dpkg -i "$NODE_FILE_NAME"
|
||||
rm -f "$NODE_FILE_NAME"
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ function build_debian() {
|
|||
/scripts/install-node $NODE_INSTALL_VERSION $YARN_INSTALL_VERSION && node --version && yarn --version
|
||||
|
||||
# Install gitlab-runner
|
||||
curl -O -J -L https://gitlab-ci-multi-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-ci-multi-runner-linux-amd64
|
||||
curl -O -J -L "https://gitlab-ci-multi-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-ci-multi-runner-linux-${TARGETARCH:-amd64}"
|
||||
mv gitlab-ci-multi-runner-linux-amd64 /usr/bin/gitlab-runner-helper
|
||||
chmod +x /usr/bin/gitlab-runner-helper
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ source "$SCRIPT_DIR/custom-docker.sh"
|
|||
|
||||
function get_base_image_reference() {
|
||||
if [[ $1 =~ ^debian ]]; then
|
||||
echo "$CUSTOM_DOCKER_ARCH/$1"
|
||||
echo "$1"
|
||||
elif [[ $1 =~ ^ubi:8 ]]; then
|
||||
echo "registry.access.redhat.com/ubi8/$1"
|
||||
fi
|
||||
|
|
@ -20,23 +20,23 @@ function print_golang_args() {
|
|||
1.16)
|
||||
INSTALL_GOLANG_VERSION=1.16.12
|
||||
GOLANG_DOWNLOAD_SHA256[amd64]=7d657e86493ac1d5892f340a7d88b862b12edb5ac6e73c099e8e0668a6c916b7
|
||||
GOLANG_DOWNLOAD_SHA256[arm64v8]=7dbf50ab2e665ecd6c86a3f1ce8c04f7167f9895b91921e25cf1bdc1cb9b5fd7
|
||||
GOLANG_DOWNLOAD_SHA256[arm64]=7dbf50ab2e665ecd6c86a3f1ce8c04f7167f9895b91921e25cf1bdc1cb9b5fd7
|
||||
;;
|
||||
1.17)
|
||||
INSTALL_GOLANG_VERSION=1.17.13
|
||||
GOLANG_DOWNLOAD_SHA256[amd64]=4cdd2bc664724dc7db94ad51b503512c5ae7220951cac568120f64f8e94399fc
|
||||
GOLANG_DOWNLOAD_SHA256[arm64v8]=914daad3f011cc2014dea799bb7490442677e4ad6de0b2ac3ded6cee7e3f493d
|
||||
GOLANG_DOWNLOAD_SHA256[arm64]=914daad3f011cc2014dea799bb7490442677e4ad6de0b2ac3ded6cee7e3f493d
|
||||
;;
|
||||
1.18)
|
||||
INSTALL_GOLANG_VERSION=1.18.5
|
||||
GOLANG_DOWNLOAD_SHA256[amd64]=9e5de37f9c49942c601b191ac5fba404b868bfc21d446d6960acc12283d6e5f2
|
||||
GOLANG_DOWNLOAD_SHA256[arm64v8]=006f6622718212363fa1ff004a6ab4d87bbbe772ec5631bab7cac10be346e4f1
|
||||
GOLANG_DOWNLOAD_SHA256[arm64]=006f6622718212363fa1ff004a6ab4d87bbbe772ec5631bab7cac10be346e4f1
|
||||
;;
|
||||
*) echo "Unknown golang version $1"; exit 1;
|
||||
esac
|
||||
|
||||
printf -- "--build-arg INSTALL_GOLANG_VERSION=%s " "$INSTALL_GOLANG_VERSION"
|
||||
printf -- "--build-arg GOLANG_DOWNLOAD_SHA256=%s " "${GOLANG_DOWNLOAD_SHA256[$CUSTOM_DOCKER_ARCH]}"
|
||||
printf -- "--build-arg GOLANG_DOWNLOAD_SHA256=%s " "${GOLANG_DOWNLOAD_SHA256[$TARGETARCH]}"
|
||||
}
|
||||
|
||||
# If you add a new minor version here, be sure to check that the
|
||||
|
|
@ -93,13 +93,13 @@ function print_lfs_args() {
|
|||
2.9)
|
||||
LFS_VERSION=2.9.1
|
||||
LFS_DOWNLOAD_SHA256[amd64]=2a8e60cf51ec45aa0f4332aa0521d60ec75c76e485d13ebaeea915b9d70ea466
|
||||
LFS_DOWNLOAD_SHA256[arm64v8]=ff2f8472a5ac0e808108bad0cc6be5ca1849eb970228b1aa3d627bcbc8228ad9
|
||||
LFS_DOWNLOAD_SHA256[arm64]=ff2f8472a5ac0e808108bad0cc6be5ca1849eb970228b1aa3d627bcbc8228ad9
|
||||
;;
|
||||
*) echo "Unknown Git LFS version $1"; exit 1;
|
||||
esac
|
||||
|
||||
printf -- "--build-arg LFS_VERSION=%s " "$LFS_VERSION"
|
||||
printf -- "--build-arg LFS_DOWNLOAD_SHA256=%s " "${LFS_DOWNLOAD_SHA256[$CUSTOM_DOCKER_ARCH]}"
|
||||
printf -- "--build-arg LFS_DOWNLOAD_SHA256=%s " "${LFS_DOWNLOAD_SHA256[$TARGETARCH]}"
|
||||
}
|
||||
|
||||
function print_node_args() {
|
||||
|
|
@ -138,13 +138,13 @@ function print_buildx_args() {
|
|||
0.8)
|
||||
BUILDX_VERSION=0.8.2
|
||||
BUILDX_DOWNLOAD_SHA256[amd64]=c64de4f3c30f7a73ff9db637660c7aa0f00234368105b0a09fa8e24eebe910c3
|
||||
BUILDX_DOWNLOAD_SHA256[arm64v8]=304d3d9822c75f98ad9cf57f0c234bcf326bbb96d791d551728cadd72a7a377f
|
||||
BUILDX_DOWNLOAD_SHA256[arm64]=304d3d9822c75f98ad9cf57f0c234bcf326bbb96d791d551728cadd72a7a377f
|
||||
;;
|
||||
*) echo "Unknown buildx version $1"; exit 1;
|
||||
esac
|
||||
|
||||
printf -- "--build-arg BUILDX_VERSION=%s " "$BUILDX_VERSION"
|
||||
printf -- "--build-arg BUILDX_DOWNLOAD_SHA256=%s " "${BUILDX_DOWNLOAD_SHA256[$CUSTOM_DOCKER_ARCH]}"
|
||||
printf -- "--build-arg BUILDX_DOWNLOAD_SHA256=%s " "${BUILDX_DOWNLOAD_SHA256[$TARGETARCH]}"
|
||||
}
|
||||
|
||||
function print_graphicsmagick_args() {
|
||||
|
|
@ -268,7 +268,7 @@ function print_kubectl_args() {
|
|||
esac
|
||||
|
||||
printf -- "--build-arg KUBECTL_VERSION=%s " "$KUBECTL_VERSION"
|
||||
printf -- "--build-arg KUBECTL_DOWNLOAD_SHA256=%s " "${KUBECTL_DOWNLOAD_SHA256[$CUSTOM_DOCKER_ARCH]}"
|
||||
printf -- "--build-arg KUBECTL_DOWNLOAD_SHA256=%s " "${KUBECTL_DOWNLOAD_SHA256[$TARGETARCH]}"
|
||||
}
|
||||
|
||||
function print_helm_args() {
|
||||
|
|
@ -284,57 +284,29 @@ function print_helm_args() {
|
|||
esac
|
||||
|
||||
printf -- "--build-arg HELM_VERSION=%s " "$HELM_VERSION"
|
||||
printf -- "--build-arg HELM_DOWNLOAD_SHA256=%s " "${HELM_DOWNLOAD_SHA256[$CUSTOM_DOCKER_ARCH]}"
|
||||
printf -- "--build-arg HELM_DOWNLOAD_SHA256=%s " "${HELM_DOWNLOAD_SHA256[$TARGETARCH]}"
|
||||
}
|
||||
|
||||
function parse_arguments() {
|
||||
printf -- "-f Dockerfile.custom "
|
||||
|
||||
# Mapping between sources of architectures
|
||||
# - arch: a current image architecture (or uname -m if matching host, but can be different)
|
||||
# - apk --print-arch: a alpine architecture for installed packages
|
||||
# - dpkg --print-architecture: a debian architecture for installed packages
|
||||
# - docker arch: a Docker Hub architecture for images
|
||||
#
|
||||
# arch | apk --print-arch | dpkg --print-architecture | docker arch
|
||||
# x86_64 | x86_64 | amd64 | amd64
|
||||
# armhf | armhf | armhf | arm32v7
|
||||
# aarch64 | aarch64 | arm64 | arm64v8
|
||||
|
||||
# We make use of 4 variables related to the build environment.
|
||||
# We make use of 2 variables related to the build environment.
|
||||
# 1. `CUSTOM_DOCKER_IMAGE` - Defines the reference of image used as
|
||||
# base for building images. Follows a
|
||||
# valid docker image reference format
|
||||
# - "arm64v8/debian:buster"
|
||||
# - "debian:buster"
|
||||
# - "registry.access.redhat.com/ubi8/ubi:8.6"
|
||||
# 2. `CUSTOM_DOCKER_ARCH` - Defines the architecture of the docker
|
||||
# image. Follows docker architecture
|
||||
# format - `amd64`/`arm32v7`/`arm64v8`.
|
||||
# 3. `BUILD_OS` - Used by installation scripts of various
|
||||
# 2. `BUILD_OS` - Used by installation scripts of various
|
||||
# components to detect the OS being worked
|
||||
# on. Follows regular docker image:tag
|
||||
# format - "debian:buster" or "ubi:8.6".
|
||||
# 4. `BUILD_ARCH` - Used by installation scripts of various
|
||||
# components to detect the architecture
|
||||
# being worked on. Follows general
|
||||
# architecture names - `amd64`/`arm64`.
|
||||
#
|
||||
# The first two variables are used to pick the docker image used as
|
||||
# base for builds. The last two variables are used to detect OS and
|
||||
# architecture while building components.
|
||||
|
||||
# defaults
|
||||
case $(arch) in
|
||||
x86_64) CUSTOM_DOCKER_ARCH=amd64; BUILD_ARCH=amd64 ;;
|
||||
aarch64) CUSTOM_DOCKER_ARCH=arm64v8; BUILD_ARCH=arm64 ;;
|
||||
*) echo "unknown architecture $(arch)"; exit 1;;
|
||||
esac
|
||||
TARGETARCH=${ARCH:-amd64}
|
||||
|
||||
for tool in "${PATH_TOOLS[@]}" "${TAG_TOOLS[@]}"; do
|
||||
if [ -n "${!tool}" ]; then
|
||||
version="${!tool}"
|
||||
case "$tool" in
|
||||
ARCH) CUSTOM_DOCKER_ARCH=$version ;;
|
||||
OS) CUSTOM_BASE_IMAGE=$(get_base_image_reference $version) ;;
|
||||
RUBY) print_ruby_args $version ;;
|
||||
BUNDLER) print_bundler_args $version ;;
|
||||
|
|
@ -358,15 +330,12 @@ function parse_arguments() {
|
|||
fi
|
||||
done
|
||||
|
||||
if [ -z "$CUSTOM_BASE_IMAGE" ]; then
|
||||
CUSTOM_BASE_IMAGE="$CUSTOM_DOCKER_ARCH/debian:buster"
|
||||
fi
|
||||
|
||||
CUSTOM_BASE_IMAGE=${CUSTOM_BASE_IMAGE:-"debian:buster"}
|
||||
BUILD_OS=${OS:-"debian:buster"}
|
||||
|
||||
printf -- "--build-arg CUSTOM_BASE_IMAGE=%s " "$CUSTOM_BASE_IMAGE"
|
||||
printf -- "--build-arg BUILD_OS=%s " "$BUILD_OS"
|
||||
printf -- "--build-arg BUILD_ARCH=%s " "$BUILD_ARCH"
|
||||
printf -- "--platform=linux/%s " "${TARGETARCH}"
|
||||
}
|
||||
|
||||
function generate_command() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue