debian-mirror-gitlab/scripts/build_assets_image

41 lines
1.8 KiB
Plaintext
Raw Normal View History

2019-02-15 15:39:39 +05:30
# Exit early if we don't want to build the image
if [[ "${BUILD_ASSETS_IMAGE}" != "true" ]]
then
2020-06-23 00:09:42 +05:30
exit 0
2019-02-15 15:39:39 +05:30
fi
2018-12-13 13:39:08 +05:30
# Generate the image name based on the project this is being run in
2019-07-07 11:18:12 +05:30
ASSETS_IMAGE_NAME="gitlab-assets-ce"
2019-12-04 20:38:33 +05:30
# `dev.gitlab-org` still has gitlab-ee.
if [[ "${CI_PROJECT_NAME}" == "gitlab" ]] || [[ "${CI_PROJECT_NAME}" == "gitlab-ee" ]]
2019-07-07 11:18:12 +05:30
then
ASSETS_IMAGE_NAME="gitlab-assets-ee"
fi
2018-12-13 13:39:08 +05:30
ASSETS_IMAGE_PATH=${CI_REGISTRY}/${CI_PROJECT_PATH}/${ASSETS_IMAGE_NAME}
mkdir -p assets_container.build/public
cp -r public/assets assets_container.build/public/
cp Dockerfile.assets assets_container.build/
2020-05-24 23:13:21 +05:30
COMMIT_REF_SLUG_DESTINATION=${ASSETS_IMAGE_PATH}:${CI_COMMIT_REF_SLUG}
2021-09-30 23:02:18 +05:30
# Use CI_MERGE_REQUEST_SOURCE_BRANCH_SHA (MR HEAD commit) so that the image is in sync with Omnibus/CNG images.
# Background: Due to the fact that we cannot retrieve the Merged Commit in the downstream omnibus/CNG pipelines,
# we're building the Omnibus/CNG images for the MR HEAD commit.
# In turn, the assets image also needs to be built from the MR HEAD commit, so that everything is build from the same commit.
# For non-MR commits, we fallback to $CI_COMMIT_SHA.
COMMIT_SHA_DESTINATION=${ASSETS_IMAGE_PATH}:${CI_MERGE_REQUEST_SOURCE_BRANCH_SHA:-$CI_COMMIT_SHA}
2021-02-22 17:27:13 +05:30
COMMIT_REF_NAME_DESTINATION=${ASSETS_IMAGE_PATH}:${CI_COMMIT_REF_NAME}
2020-05-24 23:13:21 +05:30
DESTINATIONS="--destination=$COMMIT_REF_SLUG_DESTINATION --destination=$COMMIT_SHA_DESTINATION"
2018-12-13 13:39:08 +05:30
2019-07-07 11:18:12 +05:30
# Also tag the image with GitLab version, if running on a tag pipeline, so
# other projects can simply use that instead of computing the slug.
if [ -n "$CI_COMMIT_TAG" ]; then
2020-05-24 23:13:21 +05:30
DESTINATIONS="$DESTINATIONS --destination=$COMMIT_REF_NAME_DESTINATION"
2019-07-07 11:18:12 +05:30
fi
2020-05-24 23:13:21 +05:30
echo "building assets image for destinations: $DESTINATIONS"
/kaniko/executor --context=assets_container.build --dockerfile=assets_container.build/Dockerfile.assets $DESTINATIONS