From 489f707008a7195287d70b4414d2be0ebb08b9da Mon Sep 17 00:00:00 2001 From: Gustavo Valverde Date: Fri, 22 Mar 2024 11:30:37 +0100 Subject: [PATCH] ref(build): avoid using an external cache with Docker Build Cloud --- .github/workflows/sub-build-docker-image.yml | 32 ++++++-------------- 1 file changed, 9 insertions(+), 23 deletions(-) diff --git a/.github/workflows/sub-build-docker-image.yml b/.github/workflows/sub-build-docker-image.yml index e25f4c0ba15..54c3622cb36 100644 --- a/.github/workflows/sub-build-docker-image.yml +++ b/.github/workflows/sub-build-docker-image.yml @@ -120,6 +120,15 @@ jobs: type=edge,enable={{is_default_branch}} type=schedule + # Setup Docker Buildx to use Docker Build Cloud + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v3 + with: + version: "lab:latest" + driver: cloud + endpoint: "zfnd/zebra" + - name: Authenticate to Google Cloud id: auth uses: google-github-actions/auth@v2.1.3 @@ -146,15 +155,6 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - # Setup Docker Buildx to use Docker Build Cloud - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v3 - with: - version: "lab:latest" - driver: cloud - endpoint: "zfnd/zebra" - # Build and push image to Google Artifact Registry, and possibly DockerHub - name: Build & push id: docker_build @@ -174,17 +174,3 @@ jobs: # Don't read from the cache if the caller disabled it. # https://docs.docker.com/engine/reference/commandline/buildx_build/#options no-cache: ${{ inputs.no_cache }} - # To improve build speeds, for each branch we push an additional image to the registry, - # to be used as the caching layer, using the `max` caching mode. - # - # We use multiple cache sources to confirm a cache hit, starting from a per-branch cache. - # If there's no hit, we continue with a `main` branch cache, which helps us avoid - # rebuilding cargo-chef, most dependencies, and possibly some Zebra crates. - # - # 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/${{ vars.GCP_PROJECT }}/zebra-caching/${{ inputs.image_name }}${{ inputs.tag_suffix }}:${{ env.GITHUB_REF_SLUG_URL }}-cache - type=registry,ref=us-docker.pkg.dev/${{ vars.GCP_PROJECT }}/zebra-caching/${{ inputs.image_name }}${{ inputs.tag_suffix }}:main-cache - cache-to: | - type=registry,ref=us-docker.pkg.dev/${{ vars.GCP_PROJECT }}/zebra-caching/${{ inputs.image_name }}${{ inputs.tag_suffix }}:${{ env.GITHUB_REF_SLUG_URL }}-cache,mode=max