313022c79a
Signed-off-by: Balasankar "Balu" C <balasankar@gitlab.com>
32 lines
1.2 KiB
Bash
Executable file
32 lines
1.2 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
# Exit early if we don't want to build the image
|
|
if [[ "${BUILD_ASSETS_IMAGE}" != "true" ]]
|
|
then
|
|
exit 0
|
|
fi
|
|
|
|
# Generate the image name based on the project this is being run in
|
|
ASSETS_IMAGE_NAME="gitlab-assets-ce"
|
|
if [[ "${CI_PROJECT_NAME}" == "gitlab-ee" ]]
|
|
then
|
|
ASSETS_IMAGE_NAME="gitlab-assets-ee"
|
|
fi
|
|
|
|
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/
|
|
docker build -t ${ASSETS_IMAGE_PATH}:${CI_COMMIT_REF_SLUG} -f assets_container.build/Dockerfile.assets assets_container.build/
|
|
docker tag ${ASSETS_IMAGE_PATH}:${CI_COMMIT_REF_SLUG} ${ASSETS_IMAGE_PATH}:${CI_COMMIT_SHA}
|
|
docker login -u gitlab-ci-token -p ${CI_JOB_TOKEN} ${CI_REGISTRY}
|
|
docker push ${ASSETS_IMAGE_PATH}:${CI_COMMIT_REF_SLUG}
|
|
docker push ${ASSETS_IMAGE_PATH}:${CI_COMMIT_SHA}
|
|
|
|
# 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
|
|
docker tag ${ASSETS_IMAGE_PATH}:${CI_COMMIT_REF_SLUG} ${ASSETS_IMAGE_PATH}:${CI_COMMIT_REF_NAME}
|
|
docker push ${ASSETS_IMAGE_PATH}:${CI_COMMIT_REF_NAME}
|
|
fi
|