From 734427d16f505a15d4057017831dbfa1c2a430e0 Mon Sep 17 00:00:00 2001 From: bacon Date: Thu, 21 Mar 2024 10:59:41 +0300 Subject: [PATCH] docker --- .gitlab-ci.yml | 66 +++++++++++++++++++++++++------------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6f55997..4b407c0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -99,41 +99,41 @@ Build: --label "org.opencontainers.image.version=$CI_COMMIT_REF_NAME" --tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA . -# - docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA + - docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA # Here, the goal is to tag the "master" branch as "latest" -#Push latest: -# variables: -# # We are just playing with Docker here. -# # We do not need GitLab to clone the source code. -# GIT_STRATEGY: none -# stage: push -# only: -# # Only "master" should be tagged "latest" -# - master -# script: -# # Because we have no guarantee that this job will be picked up by the same runner -# # that built the image in the previous step, we pull it again locally -# - docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA -# # Then we tag it "latest" -# - docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA $CI_REGISTRY_IMAGE:latest -# # Annnd we push it. -# - docker push $CI_REGISTRY_IMAGE:latest -# -## Finally, the goal here is to Docker tag any Git tag -## GitLab will start a new pipeline everytime a Git tag is created, which is pretty awesome -#Push tag: -# variables: -# # Again, we do not need the source code here. Just playing with Docker. -# GIT_STRATEGY: none -# stage: push -# only: -# # We want this job to be run on tags only. -# - tags -# script: -# - docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA -# - docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME -# - docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME +Push latest: + variables: + # We are just playing with Docker here. + # We do not need GitLab to clone the source code. + GIT_STRATEGY: none + stage: push + only: + # Only "master" should be tagged "latest" + - master + script: + # Because we have no guarantee that this job will be picked up by the same runner + # that built the image in the previous step, we pull it again locally + - docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA + # Then we tag it "latest" + - docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA $CI_REGISTRY_IMAGE:latest + # Annnd we push it. + - docker push $CI_REGISTRY_IMAGE:latest + +# Finally, the goal here is to Docker tag any Git tag +# GitLab will start a new pipeline everytime a Git tag is created, which is pretty awesome +Push tag: + variables: + # Again, we do not need the source code here. Just playing with Docker. + GIT_STRATEGY: none + stage: push + only: + # We want this job to be run on tags only. + - tags + script: + - docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA + - docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME + - docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME push: stage: 'deploy'