From cbb8be7441401a7e08a043fe0bd7939b373c9f87 Mon Sep 17 00:00:00 2001 From: xfy Date: Wed, 15 Jul 2026 17:36:57 +0800 Subject: [PATCH] =?UTF-8?q?feat(make):=20=E6=96=B0=E5=A2=9E=20docker-amd64?= =?UTF-8?q?=20=E4=B8=8E=20docker-apple=20=E7=9B=AE=E6=A0=87=E6=9E=84?= =?UTF-8?q?=E5=BB=BA=20x86=5F64=20=E9=95=9C=E5=83=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit docker target 只出当前宿主架构(Apple Silicon 上为 arm64),无法直接得到 x86 镜像;docker-multiarch 虽支持 amd64 但强制 --push 到 registry,无法本地 验证。补两个本地可用的 x86_64 构建 target: - docker-amd64:docker buildx --platform linux/amd64 --load,走 QEMU 交叉仿真, 产物进 Docker 本地 daemon,可直接 docker run / docker save。 - docker-apple:Apple Container CLI(macos 26 Tahoe)原生构建,无需 Docker Desktop, 用 --arch(非 --platform)。 Dockerfile 本身按 dpkg --print-architecture 自适应选 musl target,无需修改。 --- Makefile | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 02b9f88..0e6fe63 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: dev build build-linux build-freebsd freebsd-sysroot docker css css-watch clean build-libs build-editor build-codemirror build-lightbox build-core highlight-css test doc doc-open start lint fix restore-webp +.PHONY: dev build build-linux build-freebsd freebsd-sysroot docker docker-amd64 docker-apple docker-multiarch css css-watch clean build-libs build-editor build-codemirror build-lightbox build-core highlight-css test doc doc-open start lint fix restore-webp build: @cd libs && pnpm install --frozen-lockfile @@ -156,6 +156,8 @@ doc-open: # QEMU is needed. Docker Desktop ships a buildx builder that handles this. # # make docker native arch only, load into local daemon (for testing) +# make docker-amd64 x86_64 only, load into local daemon (buildx + QEMU on Apple Silicon) +# make docker-apple x86_64 only, via Apple Container CLI (macOS 26+, Apple Silicon native; no Docker needed) # make docker-multiarch build amd64+arm64 and push to a registry # (multi-arch manifests can't be --load-ed locally) # @@ -167,6 +169,18 @@ PLATFORMS ?= linux/amd64,linux/arm64 docker: @docker buildx build --load -t yggdrasil . +# Cross-build x86_64 into the local daemon. buildx 仿真非原生架构,无需修改 Dockerfile +# (它本就按 dpkg --print-architecture 自适应选 musl target)。Apple Silicon 上走 QEMU, +# 比 native 慢;产物可直接 docker run / docker save 导出。 +docker-amd64: + @docker buildx build --platform linux/amd64 --load -t yggdrasil:amd64 . + +# Apple Container CLI 构建 x86_64 镜像。前提:macOS 26 Tahoe + 已安装 `container`。 +# 无需 Docker Desktop;使用 --arch 而非 --platform(Apple Container 用裸架构名,OS 固定 linux)。 +# 产出标准 OCI 镜像,可 container push 到 registry 后在 Linux 上用 docker compose 运行。 +docker-apple: + @container build --arch amd64 -t yggdrasil:amd64 . + docker-multiarch: @docker buildx build --platform $(PLATFORMS) -t $(IMAGE) --push .