From f3934c3bf8ad2def9985411a97d36b2f204ae217 Mon Sep 17 00:00:00 2001 From: yuyr Date: Fri, 10 Jul 2026 17:36:55 +0800 Subject: [PATCH] =?UTF-8?q?20260710=20Docker=E6=9E=84=E5=BB=BA=E5=9B=BA?= =?UTF-8?q?=E5=AE=9A=E6=9C=AC=E5=9C=B0=E5=9F=BA=E7=A1=80=E9=95=9C=E5=83=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/docker/build_docker_runtime_image.sh | 36 +++++++++++++++++--- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/scripts/docker/build_docker_runtime_image.sh b/scripts/docker/build_docker_runtime_image.sh index 5902b60..271b094 100755 --- a/scripts/docker/build_docker_runtime_image.sh +++ b/scripts/docker/build_docker_runtime_image.sh @@ -55,6 +55,13 @@ safe_tag_name() { printf '%s' "$1" | tr '/:' '--' } +local_base_image_tag() { + local role="$1" + local arch="$2" + local source_image="$3" + printf 'ours-rp-base-%s-%s:%s\n' "$role" "$arch" "$(safe_tag_name "$source_image")" +} + platform_for_arch() { printf 'linux/%s\n' "$1" } @@ -168,12 +175,29 @@ mkdir -p "$OUT_DIR" target_platform="$(platform_for_arch "$TARGET_ARCH")" local_host_arch="$(host_arch)" +builder_platform="$(platform_for_arch "$local_host_arch")" +builder_source_image="$BUILDER_IMAGE" +runtime_source_image="$RUNTIME_IMAGE" +builder_local_image="$(local_base_image_tag builder "$local_host_arch" "$builder_source_image")" +runtime_local_image="$(local_base_image_tag runtime "$TARGET_ARCH" "$runtime_source_image")" if [[ "$INSTALL_BINFMT" == "1" && "$local_host_arch" != "$TARGET_ARCH" ]]; then echo "installing binfmt/qemu for $TARGET_ARCH" docker run --rm --privileged tonistiigi/binfmt --install "$TARGET_ARCH" fi +# Pulling through the Docker daemon uses its configured proxy. Buildx then consumes +# these architecture-pinned local aliases without issuing separate registry metadata +# requests for the Dockerfile FROM instructions. +echo "pulling builder base image: $builder_source_image ($builder_platform)" +docker pull --platform "$builder_platform" "$builder_source_image" +docker tag "$builder_source_image" "$builder_local_image" +echo "pulling runtime base image: $runtime_source_image ($target_platform)" +docker pull --platform "$target_platform" "$runtime_source_image" +docker tag "$runtime_source_image" "$runtime_local_image" +BUILDER_IMAGE="$builder_local_image" +RUNTIME_IMAGE="$runtime_local_image" + if [[ "$BUILDER_NAME" != "default" ]] && ! docker buildx inspect "$BUILDER_NAME" >/dev/null 2>&1; then docker buildx create --name "$BUILDER_NAME" --driver docker-container --use >/dev/null else @@ -188,8 +212,10 @@ build_log="$OUT_DIR/$(safe_tag_name "$IMAGE_TAG").build.log" echo "building $target_platform image: $IMAGE_TAG" echo "repo: $REPO_ROOT" echo "dockerfile: $DOCKERFILE" -echo "builder_image: $BUILDER_IMAGE" -echo "runtime_image: $RUNTIME_IMAGE" +echo "builder_source_image: $builder_source_image" +echo "runtime_source_image: $runtime_source_image" +echo "builder_local_image: $BUILDER_IMAGE" +echo "runtime_local_image: $RUNTIME_IMAGE" echo "source_commit: $SOURCE_COMMIT_FULL" echo "source_dirty: $SOURCE_DIRTY" echo "build_timestamp_utc: $BUILD_TIMESTAMP_UTC" @@ -248,8 +274,10 @@ fi echo "image=$IMAGE_TAG" echo "platform=$target_platform" echo "arch=$TARGET_ARCH" - echo "builder_image=$BUILDER_IMAGE" - echo "runtime_image=$RUNTIME_IMAGE" + echo "builder_image=$builder_source_image" + echo "runtime_image=$runtime_source_image" + echo "builder_local_image=$BUILDER_IMAGE" + echo "runtime_local_image=$RUNTIME_IMAGE" echo "elapsed_secs=$elapsed_secs" echo "metadata=$metadata_path" echo "tar=$tar_path"