Skip to content

Docker (BuildKit layer cache)

Avrea accelerates Docker builds by serving BuildKit's type=gha cache backend from a colocated cache instead of GitHub's remote blob storage.

No Avrea-specific configuration is needed. Use docker/build-push-action with the standard type=gha cache backend:

workflow.yml
jobs:
build:
runs-on: avrea-ubuntu-latest-2-vcpu
steps:
- uses: actions/checkout@v6
- uses: docker/setup-buildx-action@v3
- uses: docker/build-push-action@v6
with:
context: .
cache-from: type=gha
cache-to: type=gha,mode=max

On the first run, BuildKit builds all layers and exports them to the cache. On subsequent runs with unchanged inputs, every RUN step hits the cached layer and the build completes in seconds.

  • mode=max exports all layers, including intermediate build stages. Required for multi-stage builds (e.g. a build stage that compiles your app and a scratch/alpine final stage).
  • mode=min (default) exports only the final image layers. The build stage is not cached and must re-execute on every run.

Use mode=max unless you have a specific reason not to.

If you have multiple Dockerfiles or matrix builds, use scope= to isolate their caches:

cache-from: type=gha,scope=backend
cache-to: type=gha,mode=max,scope=backend

Add .git to your .dockerignore — otherwise COPY . . invalidates the layer cache on every run because .git/ contains files with different timestamps even when the same commit is checked out.

.dockerignore
.git