Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/build_gdk_image')
-rwxr-xr-xscripts/build_gdk_image52
1 files changed, 52 insertions, 0 deletions
diff --git a/scripts/build_gdk_image b/scripts/build_gdk_image
new file mode 100755
index 00000000000..292d315b5ec
--- /dev/null
+++ b/scripts/build_gdk_image
@@ -0,0 +1,52 @@
+#!/bin/bash
+
+set -e
+
+source "$(dirname "$0")/utils.sh"
+
+REGISTRY="${CI_REGISTRY}/${CI_PROJECT_PATH}"
+SHA_TAG="${CI_COMMIT_SHA}"
+BRANCH_TAG="${CI_COMMIT_REF_SLUG}"
+BASE_TAG=$([ "${BUILD_GDK_BASE}" == "true" ] && echo "${SHA_TAG}" || echo "master")
+
+if [[ -z "${GDK_SHA}" ]]; then
+ GDK_SHA=$(git ls-remote https://gitlab.com/gitlab-org/gitlab-development-kit.git main | cut -f 1)
+fi
+
+if [[ -n "${CI}" ]]; then
+ OUTPUT_OPTION="--push"
+else
+ OUTPUT_OPTION="--load"
+fi
+
+function build_image() {
+ local image=$1
+ local target=$2
+
+ echoinfo "Using GDK at SHA ${GDK_SHA}"
+
+ docker buildx build \
+ --cache-to="type=inline" \
+ --cache-from="${image}:${BRANCH_TAG}" \
+ --cache-from="${image}:master" \
+ --file="qa/gdk/Dockerfile.gdk" \
+ --target="${target}" \
+ --platform=${ARCH:-amd64} \
+ --tag="${image}:${SHA_TAG}" \
+ --tag="${image}:${BRANCH_TAG}" \
+ --build-arg="BASE_TAG=${BASE_TAG}" \
+ --build-arg="GDK_SHA=${GDK_SHA:-main}" \
+ ${OUTPUT_OPTION} \
+ .
+}
+
+# Rebuild base image when BUILD_GDK_BASE is set to true
+if [[ "${BUILD_GDK_BASE}" == "true" ]]; then
+ echoinfo "Building GDK base image", "yes"
+ build_image "${REGISTRY}/gitlab-qa-gdk-base" "gdk-base"
+fi
+
+echoinfo "Building GDK image", "yes"
+build_image "${REGISTRY}/gitlab-qa-gdk" "gdk"
+
+echosuccess "Built image '${REGISTRY}/gitlab-qa-gdk:${SHA_TAG}'"