diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml index 167e58c..f3cf3da 100644 --- a/.gitea/workflows/build.yaml +++ b/.gitea/workflows/build.yaml @@ -162,11 +162,35 @@ jobs: exit 0 fi - docker buildx build --push \ - -f Dockerfile.simple \ - --build-arg SERVICE_NAME=${{ matrix.service }} \ - --cache-from type=registry,ref=$REGISTRY_HOSTPORT/nxtgauge-rust-${{ matrix.service }}:buildcache \ - --cache-to type=registry,ref=$REGISTRY_HOSTPORT/nxtgauge-rust-${{ matrix.service }}:buildcache,mode=max \ - -t "$REGISTRY_HOSTPORT/nxtgauge-rust-${{ matrix.service }}:${{ gitea.sha }}" \ - -t "$REGISTRY_HOSTPORT/nxtgauge-rust-${{ matrix.service }}:high-performance-latest" \ - . + build_with_cache() { + docker buildx build --push \ + -f Dockerfile.simple \ + --build-arg SERVICE_NAME=${{ matrix.service }} \ + --cache-from type=registry,ref=$REGISTRY_HOSTPORT/nxtgauge-rust-${{ matrix.service }}:buildcache \ + --cache-to type=registry,ref=$REGISTRY_HOSTPORT/nxtgauge-rust-${{ matrix.service }}:buildcache,mode=max \ + -t "$REGISTRY_HOSTPORT/nxtgauge-rust-${{ matrix.service }}:${{ gitea.sha }}" \ + -t "$REGISTRY_HOSTPORT/nxtgauge-rust-${{ matrix.service }}:high-performance-latest" \ + . + } + + build_without_cache_export() { + docker buildx build --push \ + -f Dockerfile.simple \ + --build-arg SERVICE_NAME=${{ matrix.service }} \ + --cache-from type=registry,ref=$REGISTRY_HOSTPORT/nxtgauge-rust-${{ matrix.service }}:buildcache \ + -t "$REGISTRY_HOSTPORT/nxtgauge-rust-${{ matrix.service }}:${{ gitea.sha }}" \ + -t "$REGISTRY_HOSTPORT/nxtgauge-rust-${{ matrix.service }}:high-performance-latest" \ + . + } + + for attempt in 1 2 3; do + echo "Build attempt $attempt with cache export for ${{ matrix.service }}" + if build_with_cache; then + exit 0 + fi + echo "Attempt $attempt failed; retrying after backoff" + sleep $((attempt * 10)) + done + + echo "Falling back to build without cache export for ${{ matrix.service }}" + build_without_cache_export