This commit is contained in:
bacon
2024-03-21 00:27:30 +03:00
parent 0e7a32f36a
commit 641ab7c3fb

View File

@@ -85,9 +85,10 @@ services:
command: [ "dockerd-entrypoint.sh" ] command: [ "dockerd-entrypoint.sh" ]
Build: Build:
image: docker:24.0.5
stage: build stage: build
image: docker@sha256:c8bb6fa5388b56304dd770c4bc0478de81ce18540173b1a589178c0d31bfce90
services:
- docker:dind@sha256:c8bb6fa5388b56304dd770c4bc0478de81ce18540173b1a589178c0d31bfce90
script: script:
# fetches the latest image (not failing if image is not found) # fetches the latest image (not failing if image is not found)
- docker pull $CI_REGISTRY_IMAGE:latest || true - docker pull $CI_REGISTRY_IMAGE:latest || true
@@ -98,10 +99,6 @@ Build:
- > - >
docker build docker build
--pull --pull
--build-arg http_proxy=$http_proxy
--build-arg https_proxy=$https_proxy
--build-arg no_proxy=$no_proxy
--cache-from $CI_REGISTRY_IMAGE:latest
--label "org.opencontainers.image.title=$CI_PROJECT_TITLE" --label "org.opencontainers.image.title=$CI_PROJECT_TITLE"
--label "org.opencontainers.image.url=$CI_PROJECT_URL" --label "org.opencontainers.image.url=$CI_PROJECT_URL"
--label "org.opencontainers.image.created=$CI_JOB_STARTED_AT" --label "org.opencontainers.image.created=$CI_JOB_STARTED_AT"
@@ -112,38 +109,38 @@ Build:
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA - docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
# Here, the goal is to tag the "master" branch as "latest" # Here, the goal is to tag the "master" branch as "latest"
Push latest: #Push latest:
variables: # variables:
# We are just playing with Docker here. # # We are just playing with Docker here.
# We do not need GitLab to clone the source code. # # We do not need GitLab to clone the source code.
GIT_STRATEGY: none # GIT_STRATEGY: none
stage: push # stage: push
only: # only:
# Only "master" should be tagged "latest" # # Only "master" should be tagged "latest"
- master # - master
script: # script:
# Because we have no guarantee that this job will be picked up by the same runner # # 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 # # that built the image in the previous step, we pull it again locally
- docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA # - docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
# Then we tag it "latest" # # Then we tag it "latest"
- docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA $CI_REGISTRY_IMAGE:latest # - docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA $CI_REGISTRY_IMAGE:latest
# Annnd we push it. # # Annnd we push it.
- docker push $CI_REGISTRY_IMAGE:latest # - docker push $CI_REGISTRY_IMAGE:latest
#
# Finally, the goal here is to Docker tag any Git tag ## 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 ## GitLab will start a new pipeline everytime a Git tag is created, which is pretty awesome
Push tag: #Push tag:
variables: # variables:
# Again, we do not need the source code here. Just playing with Docker. # # Again, we do not need the source code here. Just playing with Docker.
GIT_STRATEGY: none # GIT_STRATEGY: none
stage: push # stage: push
only: # only:
# We want this job to be run on tags only. # # We want this job to be run on tags only.
- tags # - tags
script: # script:
- docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA # - docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
- docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME # - docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME # - docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
push: push:
stage: 'deploy' stage: 'deploy'