Skip to content
Snippets Groups Projects
Commit 6e8a56f5 authored by Yoann Schneider's avatar Yoann Schneider :tennis:
Browse files

Merge branch 'docker-latest' into 'master'

Push an image tagged `latest`

Closes #3

See merge request !3
parents 3649e8b3 cca67315
No related branches found
No related tags found
1 merge request!3Push an image tagged `latest`
Pipeline #172865 passed
......@@ -3,6 +3,7 @@
# Requires CI_PROJECT_DIR and CI_REGISTRY_IMAGE to be set.
# Will automatically login to a registry if CI_REGISTRY, CI_REGISTRY_USER and CI_REGISTRY_PASSWORD are set.
# Will only push an image if $CI_REGISTRY is set.
# Will also push an image if $CI_COMMIT_BRANCH and $CI_DEFAULT_BRANCH are set and equal.
if [ -z "$VERSION" -o -z "$CI_PROJECT_DIR" -o -z "$CI_REGISTRY_IMAGE" ]; then
echo Missing environment variables
......@@ -17,6 +18,12 @@ docker build -f Dockerfile . -t "$IMAGE_TAG"
if [ -n "$CI_REGISTRY" -a -n "$CI_REGISTRY_USER" -a -n "$CI_REGISTRY_PASSWORD" ]; then
echo $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY
docker push $IMAGE_TAG
if [ -n "$CI_COMMIT_BRANCH" -a -n "$CI_DEFAULT_BRANCH" -a "$CI_COMMIT_BRANCH" = "$CI_DEFAULT_BRANCH" ]; then
IMAGE_TAG_LATEST="$CI_REGISTRY_IMAGE:latest"
docker tag $IMAGE_TAG $IMAGE_TAG_LATEST
docker push $IMAGE_TAG_LATEST
fi
else
echo "Missing environment variables to log in to the container registry…"
fi
fi
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment