stages: - build - push variables: BUILT_IMAGE_TAG: built_image IMAGE_TAG: ${CI_REGISTRY_IMAGE} DOCKER_HUB_IMAGE_TAG: skobkin/murmur DOCKER_HUB_LOGIN: skobkin DOCKER_HUB_TOKEN: "xxx" build: # https://wiki.alpinelinux.org/wiki/Release_Notes_for_Alpine_3.14.0#faccessat2 image: docker:23.0.2 services: - docker:23.0.2-dind stage: build script: - docker build -t $BUILT_IMAGE_TAG --no-cache . - docker save -o $CI_PROJECT_DIR/images.tar $BUILT_IMAGE_TAG artifacts: paths: - images.tar push-gitlab-registry: image: docker:23.0.2 services: - docker:23.0.2-dind stage: push only: - tags script: - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY - docker load -i images.tar - 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:$CI_COMMIT_TAG push-docker-hub-registry: image: docker:23.0.2 services: - docker:23.0.2-dind stage: push only: - tags script: - docker login -u $DOCKER_HUB_LOGIN -p $DOCKER_HUB_TOKEN - docker load -i images.tar - 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:$CI_COMMIT_TAG