From 4167380f58b34500ddd7e1b37e3dd0b8f6006c4a Mon Sep 17 00:00:00 2001 From: Gustavo Valverde Date: Tue, 31 Jan 2023 16:40:55 -0400 Subject: [PATCH] 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. --- .github/workflows/build-docker-image.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-docker-image.yml b/.github/workflows/build-docker-image.yml index 7327f50b..a197e91c 100644 --- a/.github/workflows/build-docker-image.yml +++ b/.github/workflows/build-docker-image.yml @@ -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