Skip to content

A lightweight WebAssembly runtime that is fast, secure, and standards-compliant

Attempt to cache docker images in CI (#13125)

Alex Crichtone5f572a672d5
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 14fa75329c..04440157ef 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -1297,7 +1297,44 @@ jobs:
with:
submodules: true
+ # Attempt to speed up building of docker images for Linux-based binaries by
+ # using docker's recommended way of building/caching with github actions.
+ # Notably this caches layers to github actions which enables subsequent
+ # reuse in future runs. The goal here is to make this step faster while
+ # additionally reducing network flakiness since the github actions cache
+ # generally works better than upstream package servers, or at least in
+ # theory.
+ #
+ # The way that this is designed is to build the image with docker-related
+ # github actions here primarily. This populates the github actions cache
+ # but also the local docker daemon cache too. Subsequently when the actual
+ # build script runs it'll attempt to rebuild the image and it should get a
+ # bunch of cache hits from here. This way we can configure the caching here
+ # within github actions without impacting the functionality of the script
+ # itself and continue enabling it to run locally.
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@v4
+ if: ${{ matrix.env.DOCKER_IMAGE }}
+ - name: Disable some docker things that are on-by-default
+ run: |
+ echo DOCKER_BUILD_CHECKS_ANNOTATIONS=false >> $GITHUB_ENV
+ echo DOCKER_BUILD_SUMMARY=false >> $GITHUB_ENV
+ echo DOCKER_BUILD_RECORD_UPLOAD=false >> $GITHUB_ENV
+ if: ${{ matrix.env.DOCKER_IMAGE }}
+ - name: Build docker image
+ if: ${{ matrix.env.DOCKER_IMAGE }}
+ uses: docker/build-push-action@v7
+ with:
+ context: ci/docker
+ file: ${{ matrix.env.DOCKER_IMAGE }}
+ tags: build-image
+ cache-from: type=gha
+ cache-to: type=gha,mode=max
+ outputs: type=docker
+
- uses: ./.github/actions/install-ninja
+ if: '${{ !matrix.env.DOCKER_IMAGE }}'
+
- uses: ./.github/actions/install-rust
with:
toolchain: ${{ matrix.rust }}
diff --git a/ci/build-release-artifacts.sh b/ci/build-release-artifacts.sh
index 5f515e87d6..687e3c2e26 100755
--- a/ci/build-release-artifacts.sh
+++ b/ci/build-release-artifacts.sh
@@ -20,7 +20,7 @@ wrapper=""
# have precise glibc requirements for Linux platforms for example.
if [ "$DOCKER_IMAGE" != "" ]; then
if [ -f "$DOCKER_IMAGE" ]; then
- docker build --tag build-image --file $DOCKER_IMAGE ci/docker
+ docker buildx build -o type=docker --tag build-image --file $DOCKER_IMAGE ci/docker
DOCKER_IMAGE=build-image
fi