Use CI_COMMIT_REF_SLUG to tag Docker images (#2191)

We're using this because it's a builtin env variable that comes
with GitLab, and it fixes one of the annoying things about Docker
tags (e.g., you can't use all of the allowed characters in
Git branches).

One issue that I've seen a few times, is branches with either
capital letters (which was recently broken), or using the '/'
character.

This PR makes it so we always use the CI_COMMIT_REF_SLUG
when making or referencing images so that it is always consistent.

Note: this might make it slightly harder to intuit what the correct
Docker image to make (if you wanted to use the one built by CI rather
than locally). This trade off doesn't seem too hard to overcome.
This commit is contained in:
Garrison Davis 2022-08-16 13:00:37 -06:00 • committed by GitHub
parent cddd9871af
commit 584c1797cf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -139,7 +139,7 @@ build amd container fb:
before_script:
- echo "${DOCKER_DEPLOY_TOKEN}" | docker login -u ${DOCKER_DEPLOY_USER} --password-stdin ${CI_REGISTRY}
script:
- tag=${CI_REGISTRY_IMAGE}/featurebase:linux-amd64-${CI_COMMIT_REF_NAME}
- tag=${CI_REGISTRY_IMAGE}/featurebase:linux-amd64-${CI_COMMIT_REF_SLUG}
- docker build --build-arg GO_VERSION=$GOVERSION --build-arg ARCH=amd64 -t $tag -f .gitlab/Dockerfile .
- docker push $tag
- echo Created docker featurebase image with tag "$tag"
@ -252,7 +252,7 @@ run go tests idk race:
- command -v certstrap >/dev/null || go install github.com/square/certstrap@latest
- echo $PROJECT
- echo $DOCKER_PASSWORD | docker login registry.gitlab.com --username "$USERNAME" --password-stdin
- BRANCH_NAME=${CI_COMMIT_BRANCH} make test-all-race
- BRANCH_NAME=${CI_COMMIT_REF_SLUG} make test-all-race
after_script:
- make save-pilosa-logs
- make shutdown
@ -283,7 +283,7 @@ run go tests idk shard transactional:
- command -v certstrap >/dev/null || go install github.com/square/certstrap@latest
- echo $PROJECT
- echo $DOCKER_PASSWORD | docker login registry.gitlab.com --username "$USERNAME" --password-stdin
- BRANCH_NAME=${CI_COMMIT_BRANCH} make test-all
- BRANCH_NAME=${CI_COMMIT_REF_SLUG} make test-all
after_script:
- make save-pilosa-logs
- make shutdown
@ -311,7 +311,7 @@ run go tests idk 533:
- cd ./idk/
- command -v certstrap >/dev/null || go install github.com/square/certstrap@latest
- echo $DOCKER_PASSWORD | docker login registry.gitlab.com --username "$USERNAME" --password-stdin
- CONFLUENT_VERSION=5.3.3 BRANCH_NAME=${CI_COMMIT_BRANCH} make test-all
- CONFLUENT_VERSION=5.3.3 BRANCH_NAME=${CI_COMMIT_REF_SLUG} make test-all
after_script:
- make save-pilosa-logs
- make shutdown
@ -340,7 +340,7 @@ run go tests idk sasl:
- cd ./idk/
- command -v certstrap >/dev/null || go install github.com/square/certstrap@latest
- echo $DOCKER_PASSWORD | docker login registry.gitlab.com --username "$USERNAME" --password-stdin
- BRANCH_NAME=${CI_COMMIT_BRANCH} make test-all-kafka-sasl
- BRANCH_NAME=${CI_COMMIT_REF_SLUG} make test-all-kafka-sasl
after_script:
- make save-pilosa-logs
- make shutdown
@ -578,7 +578,7 @@ build arm container fb:
before_script:
- echo "${DOCKER_DEPLOY_TOKEN}" | docker login -u ${DOCKER_DEPLOY_USER} --password-stdin ${CI_REGISTRY}
script:
- tag=${CI_REGISTRY_IMAGE}/featurebase:linux-arm64-${CI_COMMIT_REF_NAME}
- tag=${CI_REGISTRY_IMAGE}/featurebase:linux-arm64-${CI_COMMIT_REF_SLUG}
- docker build --build-arg GO_VERSION=$GOVERSION --build-arg ARCH=arm64 -t $tag -f .gitlab/Dockerfile .
- docker push $tag
- echo Created docker featurebase image with tag "$tag"