From 4905d42106083568996d73aed72e8e95a9024619 Mon Sep 17 00:00:00 2001 From: dyrnq Date: Fri, 4 Oct 2024 10:21:40 +0800 Subject: [PATCH] Optimize check schemaVersion before copy --- .github/workflows/copy-open-webui.yml | 13 ++++++++++++- .github/workflows/copy.yml | 17 ++++++++++++++--- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/.github/workflows/copy-open-webui.yml b/.github/workflows/copy-open-webui.yml index fd207c3..d8dbb85 100644 --- a/.github/workflows/copy-open-webui.yml +++ b/.github/workflows/copy-open-webui.yml @@ -75,6 +75,11 @@ jobs: sudo curl -# -fSL https://github.com/dyrnq/skopeo-binary/releases/download/${SKOPEO_VER}/skopeo.tar.xz | sudo tar -xvJ -C /usr/bin sudo chmod +x /usr/bin/skopeo skopeo -v && skopeo --help + - name: Install regctl + run: | + sudo curl -# -fSL -o /usr/local/bin/regctl https://github.com/regclient/regclient/releases/download/v0.7.1/regctl-linux-amd64 + sudo chmod +x /usr/local/bin/regctl + regctl version - name: Images copy env: DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} @@ -85,4 +90,10 @@ jobs: dest=$(awk -F, '{print $2}' <<< "${line}") tag=${{ matrix.tags }} echo ${tag} - skopeo --insecure-policy copy --all --retry-times 20 --dest-precompute-digests --dest-creds $DOCKER_USERNAME:$DOCKER_PASSWORD docker://"${scr}":"${tag}" docker://"${dest}":"${tag}" + + schemaVersion=$(regctl manifest get docker://"${scr}":"${tag}" --format raw-body | jq -r '.schemaVersion') + if [ "${schemaVersion}" = "1" ]; then + echo "schemaVersion=1, skip copy" + else + skopeo --insecure-policy copy --all --retry-times 20 --dest-precompute-digests --dest-creds $DOCKER_USERNAME:$DOCKER_PASSWORD docker://"${scr}":"${tag}" docker://"${dest}":"${tag}" + fi diff --git a/.github/workflows/copy.yml b/.github/workflows/copy.yml index a2f0ee8..460393b 100644 --- a/.github/workflows/copy.yml +++ b/.github/workflows/copy.yml @@ -88,6 +88,11 @@ jobs: sudo curl -# -fSL https://github.com/dyrnq/skopeo-binary/releases/download/${SKOPEO_VER}/skopeo.tar.xz | sudo tar -xvJ -C /usr/bin sudo chmod +x /usr/bin/skopeo skopeo -v && skopeo --help + - name: Install regctl + run: | + sudo curl -# -fSL -o /usr/local/bin/regctl https://github.com/regclient/regclient/releases/download/v0.7.1/regctl-linux-amd64 + sudo chmod +x /usr/local/bin/regctl + regctl version - name: Images copy env: DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} @@ -101,9 +106,15 @@ jobs: for tag in $(skopeo list-tags docker://"${scr}" | jq -r '.Tags[]' | grep -v "sha" ) ; do - skopeo --insecure-policy copy --format v2s2 --all --retry-times 20 --dest-precompute-digests --dest-creds $DOCKER_USERNAME:$DOCKER_PASSWORD docker://"${scr}":"${tag}" docker://"${dest}":"${tag}" + # skopeo --insecure-policy copy --all --retry-times 20 --dest-precompute-digests --dest-creds $DOCKER_USERNAME:$DOCKER_PASSWORD docker://"${scr}":"${tag}" docker://"${dest}":"${tag}" + schemaVersion=$(regctl manifest get docker://"${scr}":"${tag}" --format raw-body | jq -r '.schemaVersion') + if [ "${schemaVersion}" = "1" ]; then + echo "schemaVersion=1, skip copy" + else + skopeo --insecure-policy copy --all --retry-times 20 --dest-precompute-digests --dest-creds $DOCKER_USERNAME:$DOCKER_PASSWORD docker://"${scr}":"${tag}" docker://"${dest}":"${tag}" + fi done - # skopeo --insecure-policy copy --format v2s2 --all --retry-times 5 --dest-precompute-digests --dest-creds $DOCKER_USERNAME:$DOCKER_PASSWORD docker://gcr.io/google.com/cloudsdktool/cloud-sdk:302.0.0-slim docker://docker.io/dyrnq/cloud-sdk:302.0.0-slim - # skopeo --insecure-policy copy --format v2s2 --all --retry-times 5 --dest-precompute-digests --dest-creds $DOCKER_USERNAME:$DOCKER_PASSWORD docker://gcr.io/distroless/base:debug docker://docker.io/dyrnq/distroless-base:debug \ No newline at end of file + # skopeo --insecure-policy copy --all --retry-times 5 --dest-precompute-digests --dest-creds $DOCKER_USERNAME:$DOCKER_PASSWORD docker://gcr.io/google.com/cloudsdktool/cloud-sdk:302.0.0-slim docker://docker.io/dyrnq/cloud-sdk:302.0.0-slim + # skopeo --insecure-policy copy --all --retry-times 5 --dest-precompute-digests --dest-creds $DOCKER_USERNAME:$DOCKER_PASSWORD docker://gcr.io/distroless/base:debug docker://docker.io/dyrnq/distroless-base:debug \ No newline at end of file