Created
July 12, 2025 15:19
-
-
Save viperadnan-git/bbd7e909d16d9ae3e2e93b0c1997f949 to your computer and use it in GitHub Desktop.
GitLab Docker Image Publish CI
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
build: | |
image: docker:latest | |
stage: build | |
services: | |
- docker:dind | |
variables: | |
IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG | |
LATEST_TAG: $CI_REGISTRY_IMAGE:latest | |
script: | |
- echo "$CI_REGISTRY_PASSWORD" | docker login $CI_REGISTRY -u $CI_REGISTRY_USER --password-stdin | |
- docker build -t $IMAGE_TAG . | |
- docker push $IMAGE_TAG | |
- | | |
if [ "$CI_COMMIT_REF_SLUG" = "main" ]; then | |
docker tag $IMAGE_TAG $LATEST_TAG | |
docker push $LATEST_TAG | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment