Orkestia
Blog
Registry

Build cache

Keep the BuildKit layer cache in your Orkestia Registry namespace so image builds reuse layers between runs, with one cache tag per image.

BuildKit can keep its layer cache in a registry. Keep it in your namespace, next to the image, and a build on a fresh runner reuses the layers of the previous build.

From the command line

Replace acme with your namespace and api with your image:

docker buildx build \
  --cache-from type=registry,ref=registry.orkestia.dev/acme/api:buildcache \
  --cache-to type=registry,ref=registry.orkestia.dev/acme/api:buildcache,mode=max \
  -t registry.orkestia.dev/acme/api:1.0 --push .

Docker's default builder may refuse to export a cache. If it does, create a builder once with docker buildx create --use.

In GitHub Actions

After the login step, pass the same cache reference to docker/build-push-action:

      - uses: orkestia/registry-login@v1
        id: orkestia
      - uses: docker/setup-buildx-action@v3
      - uses: docker/build-push-action@v6
        with:
          push: true
          tags: ${{ steps.orkestia.outputs.registry }}/api:${{ github.sha }}
          cache-from: type=registry,ref=${{ steps.orkestia.outputs.registry }}/api:buildcache
          cache-to: type=registry,ref=${{ steps.orkestia.outputs.registry }}/api:buildcache,mode=max

A pull request job that may only pull can still read the cache with cache-from. Leave out cache-to there, since it cannot push.

One cache tag per image

Use one cache tag per image, such as buildcache, not one per commit or branch. A cache tag per commit adds a tag every build and counts toward the 50,000 tags in one repository.

Cache data counts as stored data. When a build replaces the buildcache tag, the previous cache stays stored without a tag, like any image whose tag moved, until you delete it by digest. With mode=max, each cache export holds the layers of every build stage, so it is the larger option.

If stored data matters more to you than cache hits on intermediate stages, keep the cache inside the image instead. BuildKit's inline cache adds no separate cache image:

docker buildx build \
  --cache-from type=registry,ref=registry.orkestia.dev/acme/api:latest \
  --cache-to type=inline \
  -t registry.orkestia.dev/acme/api:latest --push .

The inline cache covers only the layers of the final image (mode=min).

Docker Hub pulls

FROM lines and docker pull from Docker Hub on Orkestia runners count against Docker Hub's anonymous pull limits for each runner. If your builds pull a lot from Docker Hub, log in to Docker Hub with your own account in the job.