feat(CI): Images avec le nom du tag dans le registre
This commit is contained in:
parent
4578e39c2d
commit
88c7fa9a47
@ -7,10 +7,22 @@ stages:
|
|||||||
- build
|
- build
|
||||||
- deploy
|
- deploy
|
||||||
|
|
||||||
|
|
||||||
|
variables:
|
||||||
|
DOCKER_IMAGE_NAME: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
|
||||||
|
|
||||||
build:
|
build:
|
||||||
stage: build
|
stage: build
|
||||||
|
before_script:
|
||||||
|
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
|
||||||
script:
|
script:
|
||||||
- docker build -t $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG .
|
- docker build --pull -t "$DOCKER_IMAGE_NAME" .
|
||||||
|
- docker push "$DOCKER_IMAGE_NAME"
|
||||||
|
- |
|
||||||
|
if [[ "$CI_COMMIT_BRANCH" == "$CI_DEFAULT_BRANCH" ]]; then
|
||||||
|
docker tag "$DOCKER_IMAGE_NAME" "$CI_REGISTRY_IMAGE:latest"
|
||||||
|
docker push "$CI_REGISTRY_IMAGE:latest"
|
||||||
|
fi
|
||||||
# Run this job in a branch where a Dockerfile exists
|
# Run this job in a branch where a Dockerfile exists
|
||||||
rules:
|
rules:
|
||||||
- if: $CI_COMMIT_BRANCH
|
- if: $CI_COMMIT_BRANCH
|
||||||
@ -19,11 +31,12 @@ build:
|
|||||||
|
|
||||||
deploy:
|
deploy:
|
||||||
stage: deploy
|
stage: deploy
|
||||||
|
before_script:
|
||||||
|
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
|
||||||
script:
|
script:
|
||||||
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
|
- docker pull $CI_REGISTRY_IMAGE:latest
|
||||||
tags:
|
- docker tag $CI_REGISTRY_IMAGE:latest $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
|
||||||
- docker
|
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
|
||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
when: on_success
|
when: on_success
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user