From eacb3d1f8a2e55f2267f49301f8277c684e67a00 Mon Sep 17 00:00:00 2001 From: steebchen Date: Tue, 3 Sep 2024 16:27:25 -0400 Subject: [PATCH] docker buildx cache local --- .github/workflows/ci.yml | 11 +++++++++-- scripts/e2e_test.sh | 12 ++++++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4ea022b..8f5be92 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,9 +26,16 @@ jobs: test: runs-on: ubuntu-latest-32-core steps: + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 - uses: actions/checkout@v4 - uses: asdf-vm/actions/install@v3 - - name: Build - run: cargo build --verbose - name: Run tests run: ./scripts/e2e_test.sh + - # Temp fix + # https://github.com/docker/build-push-action/issues/252 + # https://github.com/moby/buildkit/issues/1896 + name: Move cache + run: | + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache diff --git a/scripts/e2e_test.sh b/scripts/e2e_test.sh index 42ef5a4..d2a5ae6 100755 --- a/scripts/e2e_test.sh +++ b/scripts/e2e_test.sh @@ -3,12 +3,20 @@ set -eux IMAGE_NAME="http-prover-test" # Check if the image already exists -docker build -t $IMAGE_NAME . + if docker images | grep -q "$IMAGE_NAME"; then echo "Image $IMAGE_NAME already exists. Skipping build step." else echo "Image $IMAGE_NAME does not exist. Building the image..." - docker build -t $IMAGE_NAME . + + if [ "${CI:-}" == "true" ]; then + docker buildx build -t $IMAGE_NAME . \ + --cache-from type=local,src=/tmp/.buildx-cache \ + --cache-to type=local,dest=/tmp/.buildx-cache-new,mode=max + else + docker build -t $IMAGE_NAME . + fi + if [ $? -ne 0 ]; then echo "Failed to build the image. Exiting." exit 1