Adding automatic image tagging.

This commit is contained in:
Alexey Skobkin 2022-01-20 05:04:43 +03:00
parent 5e6aa2f1bc
commit 08bc23b31e

View file

@ -4,8 +4,8 @@ stages:
variables: variables:
BUILT_IMAGE_TAG: built_image BUILT_IMAGE_TAG: built_image
IMAGE_TAG: $CI_REGISTRY_IMAGE IMAGE_TAG: ${CI_REGISTRY_IMAGE}
DOCKER_HUB_IMAGE_TAG: "skobkin/murmur:latest" DOCKER_HUB_IMAGE_TAG: skobkin/murmur
DOCKER_HUB_LOGIN: skobkin DOCKER_HUB_LOGIN: skobkin
DOCKER_HUB_TOKEN: "xxx" DOCKER_HUB_TOKEN: "xxx"
@ -27,20 +27,28 @@ push-gitlab-registry:
services: services:
- docker:20.10.12-dind - docker:20.10.12-dind
stage: push stage: push
only:
- tags
script: script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker load -i images.tar - docker load -i images.tar
- docker tag $BUILT_IMAGE_TAG $IMAGE_TAG - docker tag $BUILT_IMAGE_TAG $IMAGE_TAG
- docker tag $BUILT_IMAGE_TAG $IMAGE_TAG:$CI_COMMIT_TAG
- docker push $IMAGE_TAG - docker push $IMAGE_TAG
- docker push $IMAGE_TAG:$CI_COMMIT_TAG
push-docker-hub-registry: push-docker-hub-registry:
image: docker:20.10.12 image: docker:20.10.12
services: services:
- docker:20.10.12-dind - docker:20.10.12-dind
stage: push stage: push
only:
- tags
script: script:
- docker login -u $DOCKER_HUB_LOGIN -p $DOCKER_HUB_TOKEN - docker login -u $DOCKER_HUB_LOGIN -p $DOCKER_HUB_TOKEN
- docker load -i images.tar - docker load -i images.tar
- docker tag $BUILT_IMAGE_TAG $DOCKER_HUB_IMAGE_TAG - docker tag $BUILT_IMAGE_TAG $DOCKER_HUB_IMAGE_TAG
- docker tag $BUILT_IMAGE_TAG $DOCKER_HUB_IMAGE_TAG:$CI_COMMIT_TAG
- docker push $DOCKER_HUB_IMAGE_TAG - docker push $DOCKER_HUB_IMAGE_TAG
- docker push $DOCKER_HUB_IMAGE_TAG::$CI_COMMIT_TAG