From 9d5972d125b6c9b614e90f435ad3a160030f722c Mon Sep 17 00:00:00 2001 From: Andrejs Cunskis Date: Mon, 22 Aug 2022 11:38:13 +0300 Subject: [PATCH] Update pipeline setup --- .gitlab-ci.yml | 1 + .gitlab/ci/definitions.yml | 26 ++++++++++++++++++-------- scripts/cache-google-chrome | 3 ++- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d2192ee..df112b8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -21,6 +21,7 @@ stages: variables: DOCKER_HOST: tcp://docker:2375 + BASE_BUILD_REGISTRY_IMAGE: registry.gitlab.com/gitlab-org/gitlab-build-images cache-chrome-chromium: extends: .cache-google-chrome diff --git a/.gitlab/ci/definitions.yml b/.gitlab/ci/definitions.yml index 16fc573..f2efa33 100644 --- a/.gitlab/ci/definitions.yml +++ b/.gitlab/ci/definitions.yml @@ -1,21 +1,27 @@ -.build_and_push: - stage: custom - needs: [] +.install-qemu: + timeout: 2 hours # builds with emulation can take a long time to complete 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 + if [ "$PUSH_CUSTOM_IMAGE" == "true" ]; then + echo "$CI_REGISTRY_PASSWORD" | docker login "$CI_REGISTRY" -u "$CI_REGISTRY_USER" --password-stdin + fi + - | + if [[ "${ARCH:-amd64}" =~ arm64 ]]; 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 + +.build_and_push: + stage: custom + extends: .install-qemu + needs: [] script: - ./scripts/lib/custom-docker-build rules: @@ -33,16 +39,20 @@ .cache-google-chrome: stage: automation + extends: .install-qemu needs: [] + variables: + ARCH: linux/amd64,linux/arm64 before_script: - - docker buildx create --use + - !reference [.install-qemu, before_script] + - docker buildx create --use # creates context that's capable of building multiple architectures in parallel script: - | docker buildx build \ --build-arg CI_API_V4_URL=$CI_API_V4_URL \ --build-arg CI_PROJECT_ID=$CI_PROJECT_ID \ --build-arg CI_JOB_TOKEN=$CI_JOB_TOKEN \ - --platform linux/amd64,linux/arm64 \ + --platform $ARCH \ -f "Dockerfile.cache-chrome" \ . rules: diff --git a/scripts/cache-google-chrome b/scripts/cache-google-chrome index 2dd7795..627a522 100755 --- a/scripts/cache-google-chrome +++ b/scripts/cache-google-chrome @@ -84,8 +84,9 @@ function cache-chromium() { fi } +echo "Updating system utils" apt-get -y -qq update -apt-get -y install apt-utils curl bash gnupg2 > /dev/null +apt-get -y install apt-utils curl gnupg2 > /dev/null if [ "$TARGETARCH" == "amd64" ]; then cache-chrome