mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-09-11 21:20:39 +02:00
Speeds of 1MB/s and 15 minute cached docker image pulls during builds are not uncommon. Warp runners provide a local GitHub Actions cache protocol proxy for Docker layer cache traffic. Point BuildKit's gha cache backend at that proxy on Warp runners so cached image layers do not have to be fetched from GitHub's slower cache service. Add a default for provider so other users (e.g. qa-assets) don't have to update this unless they use custome runners.
57 lines
2.1 KiB
YAML
57 lines
2.1 KiB
YAML
name: 'Configure Docker'
|
||
description: 'Set up Docker build driver and configure build cache args'
|
||
inputs:
|
||
provider:
|
||
description: 'The cache provider to use'
|
||
required: false
|
||
default: 'gha'
|
||
runs:
|
||
using: 'composite'
|
||
steps:
|
||
- name: Set up Docker Buildx for Warp cache
|
||
if: ${{ inputs.provider == 'warp' }}
|
||
uses: docker/setup-buildx-action@v4
|
||
with:
|
||
driver-opts: |
|
||
network=host
|
||
|
||
- name: Set up Docker Buildx
|
||
if: ${{ inputs.provider != 'warp' }}
|
||
uses: docker/setup-buildx-action@v4
|
||
|
||
# This is required when using the gha cache backend with a manual docker buildx invocation.
|
||
# Docker will check for variables $ACTIONS_CACHE_URL, $ACTIONS_RESULTS_URL and $ACTIONS_RUNTIME_TOKEN
|
||
# which are set automatically when running on GitHub infra: https://docs.docker.com/build/cache/backends/gha/#synopsis
|
||
- name: Expose actions cache variables
|
||
uses: actions/github-script@v8
|
||
with:
|
||
script: |
|
||
Object.keys(process.env).forEach(function (key) {
|
||
if (key.startsWith('ACTIONS_')) {
|
||
core.info(`Exporting ${key}`);
|
||
core.exportVariable(key, process.env[key]);
|
||
}
|
||
});
|
||
|
||
- name: Construct docker build cache args
|
||
shell: bash
|
||
run: |
|
||
cache_options="scope=${CONTAINER_NAME}"
|
||
if [[ "${{ inputs.provider }}" == "warp" ]]; then
|
||
cache_options="url=http://127.0.0.1:49160/,version=1,${cache_options}"
|
||
fi
|
||
|
||
# Configure docker build cache backend
|
||
# Always optimistically --cache‑from in case a cache blob exists
|
||
args=(--cache-from "type=gha,${cache_options}")
|
||
|
||
# Only add --cache-to when pushing to the default branch.
|
||
if [[ ${{ github.event_name }} == "push" && ${{ github.ref_name }} == ${{ github.event.repository.default_branch }} ]]; then
|
||
args+=(--cache-to "type=gha,mode=max,ignore-error=true,${cache_options}")
|
||
fi
|
||
|
||
# Always `--load` into docker images (needed when using the `docker-container` build driver).
|
||
args+=(--load)
|
||
|
||
echo "DOCKER_BUILD_CACHE_ARG=${args[*]}" >> $GITHUB_ENV
|