Files
BYW-VoiceHub/patches/0021-perf-ci-buildx-builder-moby-buildkit-registry-mirror.patch
T

78 lines
3.7 KiB
Diff
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
From 7b8dabdb49cb6d65a1273288ed623adc9df1bfd6 Mon Sep 17 00:00:00 2001
From: HenryDu8133 <813367384@qq.com>
Date: Sun, 6 Sep 2026 12:19:49 +0800
Subject: [PATCH 21/58] =?UTF-8?q?perf(ci):=20buildx=20builder=20=E9=A2=84?=
=?UTF-8?q?=E6=8B=89=20moby/buildkit=20=E8=B5=B0=E5=9B=BD=E5=86=85=20regis?=
=?UTF-8?q?try-mirrors=EF=BC=8C=E6=8F=90=E9=80=9F=E5=90=AF=E5=8A=A8=205-10?=
=?UTF-8?q?=20=E5=80=8D?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.gitea/workflows/deploy.yml | 33 +++++++++++++++++++++++++++------
1 file changed, 27 insertions(+), 6 deletions(-)
diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml
index aaceb9b..e2010ff 100644
--- a/.gitea/workflows/deploy.yml
+++ b/.gitea/workflows/deploy.yml
@@ -205,6 +205,7 @@ jobs:
run: |
set -euxo pipefail
BUILDER_NAME="multi"
+ BUILDKIT_IMAGE="moby/buildkit:buildx-stable-1"
BKK_CFG="$(mktemp -t buildkitd_XXXXXX.toml)"
# 用 printf 逐行写 buildkitd 配置,避免 YAML parser 把 heredoc 内部的 [...] 误判为 YAML key
{
@@ -213,6 +214,24 @@ jobs:
printf '[registry."ghcr.io"]\n mirrors = ["ghcr.nju.edu.cn","ghcr.dockerproxy.com"]\n\n'
printf '[registry."k8s.gcr.io"]\n mirrors = ["k8s-gcr.m.daocloud.io","registry.cn-hangzhou.aliyuncs.com/google_containers"]\n'
} > "${BKK_CFG}"
+ # 预拉 buildkitd 基础镜像(优先 5 个国内镜像 fallback,避免 Docker Hub <200KB/s)
+ PULLED=0
+ for MIRROR in \
+ "docker.m.daocloud.io/${BUILDKIT_IMAGE}" \
+ "dockerproxy.com/${BUILDKIT_IMAGE}" \
+ "hub-mirror.c.163.com/${BUILDKIT_IMAGE}" \
+ "docker.nju.edu.cn/${BUILDKIT_IMAGE}" \
+ "docker.mirrors.ustc.edu.cn/${BUILDKIT_IMAGE}" \
+ "${BUILDKIT_IMAGE}"; do
+ if docker pull "${MIRROR}" 2>/dev/null; then
+ if [ "${MIRROR}" != "${BUILDKIT_IMAGE}" ]; then
+ docker tag "${MIRROR}" "${BUILDKIT_IMAGE}" 2>/dev/null || true
+ fi
+ PULLED=1
+ break
+ fi
+ done
+ [ "${PULLED}" = "1" ] || { echo "ERROR: 无法拉取 buildkitd 基础镜像,请检查 Docker registry-mirrors"; exit 1; }
docker buildx rm "${BUILDER_NAME}" 2>/dev/null || true
docker buildx create \
--name "${BUILDER_NAME}" \
@@ -220,13 +239,15 @@ jobs:
--use \
--config "${BKK_CFG}" \
--buildkitd-flags '--allow-insecure-entitlement security.insecure --allow-insecure-entitlement network.host' \
- --driver-opt network=host
+ --driver-opt network=host \
+ --driver-opt "image=${BUILDKIT_IMAGE}"
rm -f "${BKK_CFG}"
- export GIT_CONFIG_COUNT=2
- export GIT_CONFIG_KEY_0="url.${GH_PROXY_PREFIX}https://github.com/.insteadOf"
- export GIT_CONFIG_VALUE_0="https://github.com/"
- export GIT_CONFIG_KEY_1="url.${GH_PROXY_PREFIX}https://gist.github.com/.insteadOf"
- export GIT_CONFIG_VALUE_1="https://gist.github.com/"
+ # gh-proxy 环境(全变量显式赋值,避免 bash tracing 边界反引号歧义)
+ GIT_CONFIG_KEY_0="url.${GH_PROXY_PREFIX}https://github.com/.insteadOf"
+ GIT_CONFIG_VALUE_0="https://github.com/"
+ GIT_CONFIG_KEY_1="url.${GH_PROXY_PREFIX}https://gist.github.com/.insteadOf"
+ GIT_CONFIG_VALUE_1="https://gist.github.com/"
+ export GIT_CONFIG_COUNT=2 GIT_CONFIG_KEY_0 GIT_CONFIG_VALUE_0 GIT_CONFIG_KEY_1 GIT_CONFIG_VALUE_1
docker buildx inspect --bootstrap
- name: 登录 Gitea 容器仓库
--
2.45.1.windows.1