feat: add multi-platform Docker image support (amd64 + arm64)#135
Open
tianshanghong wants to merge 2 commits into
Open
feat: add multi-platform Docker image support (amd64 + arm64)#135tianshanghong wants to merge 2 commits into
tianshanghong wants to merge 2 commits into
Conversation
Add QEMU and Docker Buildx setup to the CI workflow to build multi-architecture Docker images for both linux/amd64 and linux/arm64. The existing Dockerfile already uses `node:lts-alpine` which natively supports multiple architectures, so no Dockerfile changes are needed. This eliminates the need for QEMU userspace emulation at runtime when running BroadcastChannel on ARM64 hosts (e.g., Apple Silicon, AWS Graviton, Ampere, Raspberry Pi), improving both performance and resource usage.
Author
|
你好!我在 ARM64 服务器上用 Docker 跑 BroadcastChannel,目前镜像只有 amd64,需要 QEMU 模拟运行,系统负载比较高。 这个 PR 只改了 CI workflow(加了 3 行),Dockerfile 不需要动,因为 已经在 fork 上跑过 CI,构建和推送都没问题:
manifest 验证: {
"manifests": [
{
"platform": { "architecture": "amd64", "os": "linux" }
},
{
"platform": { "architecture": "arm64", "os": "linux" }
}
]
}对现有 amd64 用户没有影响,CI 时间大概多 1-2 分钟。 相关 issue:#136 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds multi-platform Docker image support for both
linux/amd64andlinux/arm64by configuring QEMU and Docker Buildx in the existing CI workflow.Problem
The current Docker image is only built for
linux/amd64. Users running BroadcastChannel on ARM64 hosts (e.g., Apple Silicon Macs, AWS Graviton, Ampere Altra, Raspberry Pi, Oracle Cloud ARM instances) must rely on QEMU userspace emulation at runtime to translate x86_64 instructions, which:Solution
Added three lines to
.github/workflows/docker.yml:docker/setup-qemu-action@v3— Installs QEMU user-mode emulation for cross-platform buildsdocker/setup-buildx-action@v3— Sets up Docker Buildx, required for multi-platform buildsplatforms: linux/amd64,linux/arm64— Specifies target architectures fordocker/build-push-actionNo changes to the
Dockerfileare required —node:lts-alpinealready provides multi-architecture base images.Impact
amd64users: No change in behaviorTesting
Dockerfileusesnode:lts-alpineas its base image, which officially supports bothamd64andarm64architectures