fix(docker): do not mix cache images with test images (#6038)

Docker does not allow to use multiple tags for cache images in their
`cache-from` and `cache-to` options. Which makes some images to lose
previous tags, if the same.

This cause automated mechanims for deletion to fail, as those cache images
were dependant on the main image, and deleting the cache alone was raising
an error if the main image was not deleted first.

A workaround for this is making a separate repository which can hold this
cache images. Which also reduces clutter from the main registries.
This commit is contained in:
Gustavo Valverde 2023-01-31 16:40:55 -04:00 committed by GitHub
parent 333b5eadd4
commit 4167380f58
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 4 deletions

View File

@ -84,7 +84,6 @@ jobs:
type=ref,event=pr
type=sha
# edge is the latest commit on the default branch.
# TODO: We only want edge builds for `us-docker.pkg.dev`, because DockerHub doesn't keep up with every `main` branch commit.
type=edge,enable={{is_default_branch}}
# Setup Docker Buildx to allow use of docker cache layers from GH
@ -158,6 +157,7 @@ jobs:
# The caches are tried in top-down order, the first available cache is used:
# https://github.com/moby/moby/pull/26839#issuecomment-277383550
cache-from: |
type=registry,ref=us-docker.pkg.dev/zealous-zebra/zebra/${{ inputs.image_name }}:${{ env.GITHUB_REF_SLUG_URL }}-cache
type=registry,ref=us-docker.pkg.dev/zealous-zebra/zebra/${{ inputs.image_name }}:main-cache
cache-to: type=registry,ref=us-docker.pkg.dev/zealous-zebra/zebra/${{ inputs.image_name }}:${{ env.GITHUB_REF_SLUG_URL }}-cache,mode=max
type=registry,ref=us-docker.pkg.dev/zealous-zebra/zebra-caching/${{ inputs.image_name }}:${{ env.GITHUB_REF_SLUG_URL }}-cache
type=registry,ref=us-docker.pkg.dev/zealous-zebra/zebra-caching/${{ inputs.image_name }}:main-cache
cache-to: |
type=registry,ref=us-docker.pkg.dev/zealous-zebra/zebra-caching/${{ inputs.image_name }}:${{ env.GITHUB_REF_SLUG_URL }}-cache,mode=max