build_docker_container:
stage: dockerize
script:
- git checkout master
- git pull
- export TAG_TO_BUILD=$(git describe --abbrev=0 --tags)
- test -z "${TAG_TO_BUILD}" && echo "The TAG_TO_BUILD is empty" && exit 1
- git reset --hard "${TAG_TO_BUILD}"
- docker login -u "$CI_REGISTRY_USER" -p $CI_JOB_TOKEN $CI_REGISTRY
- docker build --pull -t "$CI_REGISTRY_IMAGE/$CI_PROJECT_NAME-$CI_COMMIT_REF_SLUG:${TAG_TO_BUILD}" .
- docker push "$CI_REGISTRY_IMAGE/$CI_PROJECT_NAME-$CI_COMMIT_REF_SLUG:${TAG_TO_BUILD}"