2019-11-01 23:48:59 +00:00
|
|
|
#! /bin/bash
|
|
|
|
|
|
|
|
IMAGE_PUSH="${1:---skip}"
|
|
|
|
IMAGE_DEFAULT="${2:---skip}"
|
|
|
|
|
|
|
|
IMAGE_NAME="${CI_PROJECT_PATH}"
|
|
|
|
IMAGE_TAG="$(echo "${CI_COMMIT_TAG:-${CI_COMMIT_REF_SLUG}}" | sed -r 's/[^-_a-zA-Z0-9\\.]/-/g')"
|
|
|
|
|
2019-11-02 01:04:55 +00:00
|
|
|
IMAGE_SHORT="${IMAGE_NAME}:${IMAGE_TAG}"
|
2019-11-01 23:48:59 +00:00
|
|
|
IMAGE_FULL="${IMAGE_NAME}:${IMAGE_TAG}-${IMAGE_ARCH}"
|
|
|
|
|
|
|
|
echo "Building image: ${IMAGE_FULL}"
|
|
|
|
|
2022-02-06 19:22:22 +00:00
|
|
|
docker build -f "Dockerfile.${IMAGE_ARCH}" -t "${IMAGE_FULL}" . || echo "Failed to build image!" && exit 1
|
2019-11-01 23:48:59 +00:00
|
|
|
|
|
|
|
if [[ "${IMAGE_PUSH}" == "--push" ]];
|
|
|
|
then
|
|
|
|
echo "Pushing image: ${IMAGE_FULL}"
|
2022-02-06 19:22:22 +00:00
|
|
|
docker push "${IMAGE_FULL}" || echo "Failed to push image!" && exit 1
|
2019-11-01 23:48:59 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ "${IMAGE_DEFAULT}" == "--default" ]];
|
|
|
|
then
|
|
|
|
echo "Pushing image (default architecture): ${IMAGE_SHORT}"
|
|
|
|
docker tag "${IMAGE_FULL}" "${IMAGE_SHORT}"
|
2022-02-06 19:22:22 +00:00
|
|
|
docker push "${IMAGE_SHORT}" || echo "Failed to push image!" && exit 1
|
2019-11-01 23:48:59 +00:00
|
|
|
fi
|