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

build_gdk_image « scripts - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 292d315b5ec3c39cf84b5d926d3e5904e2fadd80 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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}'"