2019-09-21 10:32:44 +00:00
|
|
|
#! /bin/bash
|
2019-09-21 10:05:51 +00:00
|
|
|
|
|
|
|
IMAGE_PUSH="${1:---skip}"
|
|
|
|
|
2019-09-21 10:32:44 +00:00
|
|
|
IMAGE_NAME="${CI_PROJECT_PATH}"
|
|
|
|
IMAGE_TAG="$(echo "${CI_COMMIT_TAG:-${CI_COMMIT_REF_SLUG}}" | sed -r 's/[^-_a-zA-Z0-9]/-/g')"
|
|
|
|
IMAGE_FULL="${IMAGE_NAME}:${IMAGE_TAG}"
|
2019-09-21 10:05:51 +00:00
|
|
|
|
2019-09-21 10:32:44 +00:00
|
|
|
echo "Building image: ${IMAGE_FULL}"
|
|
|
|
|
2019-09-23 13:13:44 +00:00
|
|
|
docker build -t "${IMAGE_FULL}" .
|
2019-09-21 10:05:51 +00:00
|
|
|
|
|
|
|
if [[ "${IMAGE_PUSH}" == "--push" ]];
|
|
|
|
then
|
2019-09-21 10:32:44 +00:00
|
|
|
echo "Pushing image: ${IMAGE_FULL}"
|
2019-09-23 13:13:44 +00:00
|
|
|
docker push "${IMAGE_FULL}"
|
2019-09-21 10:05:51 +00:00
|
|
|
fi
|