From 933973311f4ff7ca7d5d5dd60e26eb9bcb7e3e60 Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Tue, 21 Jul 2026 13:54:09 +0800 Subject: [PATCH] =?UTF-8?q?perf(ci):=20=E6=81=A2=E5=A4=8Dregistry=20cache-?= =?UTF-8?q?to=E5=86=99=E5=85=A5=EF=BC=8CACR=E5=B7=B2=E6=94=B9=E4=B8=BAtag?= =?UTF-8?q?=E5=8F=AF=E5=8F=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 恢复2处--cache-to type=registry写入 - 保留ignore-error=true作为兜底(防止ACR配置回退导致构建失败) - cache-from的ignore-error也去掉了(tag可变后正常写入不会报错) 前提:阿里云ACR缓存仓库(api-cache/worker-cache/web-cache)已从不可变改为可变tag --- scripts/ci/docker_build_push.sh | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/scripts/ci/docker_build_push.sh b/scripts/ci/docker_build_push.sh index af4962a55..f3ba4bb80 100755 --- a/scripts/ci/docker_build_push.sh +++ b/scripts/ci/docker_build_push.sh @@ -1,6 +1,5 @@ #!/bin/bash -# 通用Docker镜像构建+推送脚本(local cache为主 + registry cache兜底) -# M-2优化:解决registry缓存导入慢(247s)和推送不稳定问题 +# 通用Docker镜像构建+推送脚本(local cache为主 + registry cache共享) # 用法: docker_build_push.sh [--no-cache] [build_arg...] set -eu @@ -35,7 +34,7 @@ LOCAL_CACHE_DIR="/tmp/buildx-cache/${CACHE_NAME}" mkdir -p "$LOCAL_CACHE_DIR" -# 缓存源:local优先(带自动修复),registry兜底 +# 缓存源:local优先(带自动修复),registry兜底读写 # 本地缓存损坏时自动清理后重试,避免snapshot not found导致构建全挂 build_with_cache_retry() { local attempt=1 @@ -48,8 +47,9 @@ build_with_cache_retry() { $NO_CACHE_FLAG \ $BUILD_ARGS \ --cache-from "type=local,src=${LOCAL_CACHE_DIR}" \ - --cache-from "type=registry,ref=${CACHE_REF},ignore-error=true" \ + --cache-from "type=registry,ref=${CACHE_REF}" \ --cache-to "type=local,dest=${LOCAL_CACHE_DIR},mode=max" \ + --cache-to "type=registry,ref=${CACHE_REF},mode=max,ignore-error=true" \ -f "${DOCKERFILE}" \ -t "${IMAGE_TAG}" \ --push \ @@ -81,15 +81,16 @@ build_with_cache_retry() { docker buildx build \ $NO_CACHE_FLAG \ $BUILD_ARGS \ - --cache-from "type=registry,ref=${CACHE_REF},ignore-error=true" \ + --cache-from "type=registry,ref=${CACHE_REF}" \ --cache-to "type=local,dest=${LOCAL_CACHE_DIR},mode=max" \ + --cache-to "type=registry,ref=${CACHE_REF},mode=max,ignore-error=true" \ -f "${DOCKERFILE}" \ -t "${IMAGE_TAG}" \ --push \ . } -echo "=== Step 1: Build & push image (local cache + registry read, with auto-repair) ===" +echo "=== Step 1: Build & push image (local cache + registry cache, with auto-repair) ===" echo "Local cache: ${LOCAL_CACHE_DIR}" echo "Registry cache: ${CACHE_REF}" echo "" @@ -99,6 +100,7 @@ build_with_cache_retry echo "" echo "Image pushed: ${IMAGE_TAG}" echo "Local cache updated" +echo "Registry cache updated (if supported)" echo "" echo "Build completed: ${IMAGE_TAG}" -- 2.54.0