Skip to content

Faster docker builds with S3-backed cache

RunsOn comes with an integrated S3 cache backend, which is what allows much faster and unlimited GitHub Actions caching with our drop-in replacement runs-on/cache action.

This S3 cache backend can also be used to cache Docker layers, to greatly speedup your docker builds.

Using the S3 cache for docker layer caching

Simply configure the S3 buildx cache backend and youโ€™re good to go:

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: "Build and push image"
uses: docker/build-push-action@v4
with:
context: "."
push: true
tags: <your-tag>
cache-from: type=s3,blobs_prefix=cache/${{ github.repository }}/,manifests_prefix=cache/${{ github.repository }}/,region=${{ env.RUNS_ON_AWS_REGION }},bucket=${{ env.RUNS_ON_S3_BUCKET_CACHE }}
cache-to: type=s3,blobs_prefix=cache/${{ github.repository }}/,manifests_prefix=cache/${{ github.repository }}/,region=${{ env.RUNS_ON_AWS_REGION }},bucket=${{ env.RUNS_ON_S3_BUCKET_CACHE }},mode=max

Authentication is handled automatically, as long as your GitHub Actions workflow is running on a RunsOn runner. Buildx will use the IAM role of the runner to access the S3 bucket.

Note that all RunsOn runners have the IAM role to access the S3 bucket. This means you can share layers across repositories and workflows within a single organization, but make sure you are ok with this.

If you require stronger isolation, you can configure multiple RunsOn stacks and use environments to isolate different workflows.