debian-mirror-gitlab/scripts/build_qa_image
2023-03-17 16:20:25 +05:30

45 lines
1.6 KiB
Bash
Executable file

#!/bin/bash
QA_IMAGE_NAME="gitlab-ee-qa"
QA_BUILD_TARGET="ee"
if [[ "${CI_PROJECT_NAME}" == "gitlabhq" || "${CI_PROJECT_NAME}" == "gitlab-foss" || "${FOSS_ONLY}" == "1" ]]; then
QA_IMAGE_NAME="gitlab-ce-qa"
QA_BUILD_TARGET="foss"
fi
# Tag with commit SHA by default
QA_IMAGE="${CI_REGISTRY}/${CI_PROJECT_PATH}/${QA_IMAGE_NAME}:${CI_COMMIT_SHA}"
# For branches, tag with slugified branch name. For tags, use the tag directly
# with v prefix removed
IMAGE_TAG=${CI_COMMIT_TAG#v}
IMAGE_TAG=${IMAGE_TAG:-$CI_COMMIT_REF_SLUG}
QA_IMAGE_BRANCH="${CI_REGISTRY}/${CI_PROJECT_PATH}/${QA_IMAGE_NAME}:${IMAGE_TAG}"
QA_IMAGE_MASTER="${CI_REGISTRY}/${CI_PROJECT_PATH}/${QA_IMAGE_NAME}:master"
DESTINATIONS="--tag ${QA_IMAGE} --tag ${QA_IMAGE_BRANCH}"
# Auto-deploy tag format uses first 12 letters of commit SHA. Tag with that
# reference also for EE images.
if [ "${QA_IMAGE_NAME}" == "gitlab-ee-qa" ]; then
QA_IMAGE_FOR_AUTO_DEPLOY="${CI_REGISTRY}/${CI_PROJECT_PATH}/${QA_IMAGE_NAME}:${CI_COMMIT_SHA:0:11}"
DESTINATIONS="${DESTINATIONS} --tag $QA_IMAGE_FOR_AUTO_DEPLOY"
fi
echo "Building QA image for '${QA_BUILD_TARGET}' for destinations: ${DESTINATIONS}"
docker buildx build \
--cache-to=type=inline \
--cache-from="$QA_IMAGE_BRANCH" \
--cache-from="$QA_IMAGE_MASTER" \
--platform=${ARCH:-amd64} \
--build-arg=CHROME_VERSION="${CHROME_VERSION}" \
--build-arg=DOCKER_VERSION="${DOCKER_VERSION}" \
--build-arg=RUBY_VERSION="${RUBY_VERSION}" \
--build-arg=QA_BUILD_TARGET="${QA_BUILD_TARGET}" \
--file="${CI_PROJECT_DIR}/qa/Dockerfile" \
--push \
${DESTINATIONS} \
${CI_PROJECT_DIR}