2018-11-14 12:36:02 -05:00
|
|
|
# Exit early if we don't want to build the image
|
|
|
|
if [[ "${BUILD_ASSETS_IMAGE}" != "true" ]]
|
|
|
|
then
|
2020-06-10 14:09:15 -04:00
|
|
|
exit 0
|
2018-11-14 12:36:02 -05:00
|
|
|
fi
|
|
|
|
|
2018-10-09 14:26:43 -04:00
|
|
|
# Generate the image name based on the project this is being run in
|
2019-03-15 09:37:09 -04:00
|
|
|
ASSETS_IMAGE_NAME="gitlab-assets-ce"
|
2019-09-18 14:06:14 -04:00
|
|
|
# `dev.gitlab-org` still has gitlab-ee.
|
|
|
|
if [[ "${CI_PROJECT_NAME}" == "gitlab" ]] || [[ "${CI_PROJECT_NAME}" == "gitlab-ee" ]]
|
2019-03-15 06:41:43 -04:00
|
|
|
then
|
|
|
|
ASSETS_IMAGE_NAME="gitlab-assets-ee"
|
|
|
|
fi
|
2018-10-09 14:26:43 -04:00
|
|
|
|
|
|
|
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-04-28 08:09:44 -04:00
|
|
|
|
|
|
|
COMMIT_REF_SLUG_DESTINATION=${ASSETS_IMAGE_PATH}:${CI_COMMIT_REF_SLUG}
|
2022-09-02 05:10:27 -04:00
|
|
|
|
|
|
|
COMMIT_SHA_DESTINATION=${ASSETS_IMAGE_PATH}:${CI_COMMIT_SHA}
|
2020-11-24 07:09:17 -05:00
|
|
|
COMMIT_REF_NAME_DESTINATION=${ASSETS_IMAGE_PATH}:${CI_COMMIT_REF_NAME}
|
2020-04-28 08:09:44 -04:00
|
|
|
|
|
|
|
DESTINATIONS="--destination=$COMMIT_REF_SLUG_DESTINATION --destination=$COMMIT_SHA_DESTINATION"
|
2018-10-09 14:26:43 -04:00
|
|
|
|
2019-03-12 07:07:56 -04:00
|
|
|
# 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-04-28 08:09:44 -04:00
|
|
|
DESTINATIONS="$DESTINATIONS --destination=$COMMIT_REF_NAME_DESTINATION"
|
2019-03-12 07:07:56 -04:00
|
|
|
fi
|
2020-04-28 08:09:44 -04:00
|
|
|
|
|
|
|
echo "building assets image for destinations: $DESTINATIONS"
|
|
|
|
|
|
|
|
/kaniko/executor --context=assets_container.build --dockerfile=assets_container.build/Dockerfile.assets $DESTINATIONS
|