Skip to content

一分钟搭建影视站,支持Docker等部署方式

ci(docker): 多架构构建改用原生 ARM64 runner,弃用 QEMU

bestZweief73553387eb
diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml
index 9251577..d5544c0 100644
--- a/.github/workflows/docker-publish.yml
+++ b/.github/workflows/docker-publish.yml
@@ -3,6 +3,10 @@ name: docker-publish
# 推送版本 tag(如 v2.0.1)时自动构建并发布镜像到 GHCR;
# 也可在 Actions 页面手动触发。
# 无需配置任何 secrets:使用内置 GITHUB_TOKEN 推送 ghcr.io。
+#
+# 多架构构建拆分:amd64 与 arm64 各自跑在原生 runner 上(GitHub 公开仓库
+# 免费提供 ubuntu-24.04-arm),按 digest 推送后合并 manifest。QEMU 跨架构
+# 模拟 npm ci / next build 极慢且不稳(Illegal instruction 崩溃),不再使用。
on:
push:
@@ -43,9 +47,13 @@ jobs:
- run: npm run typecheck
- run: npm test
- publish:
+ build:
needs: verify
- runs-on: ubuntu-latest
+ strategy:
+ fail-fast: false
+ matrix:
+ platform: [linux/amd64, linux/arm64]
+ runs-on: ${{ matrix.platform == 'linux/arm64' && 'ubuntu-24.04-arm' || 'ubuntu-latest' }}
steps:
- uses: actions/checkout@v4
@@ -54,7 +62,6 @@ jobs:
id: image
run: echo "name=${REGISTRY}/${GITHUB_REPOSITORY,,}" >> "$GITHUB_OUTPUT"
- - uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
@@ -63,7 +70,64 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- # tag v2.0.1 → 2.0.1 / 2.0 / latest 三个标签
+ # tag v2.0.1 → 2.0.1 / 2.0 / latest 三个标签(在 merge job 里统一打)
+ - id: meta
+ uses: docker/metadata-action@v5
+ with:
+ images: ${{ steps.image.outputs.name }}
+ tags: |
+ type=semver,pattern={{version}}
+ type=semver,pattern={{major}}.{{minor}}
+ type=raw,value=latest
+
+ # 按架构各推一个镜像层(无 tag,由 digest 标识),标签在 merge 阶段合并
+ - id: build
+ uses: docker/build-push-action@v6
+ with:
+ context: .
+ platforms: ${{ matrix.platform }}
+ labels: ${{ steps.meta.outputs.labels }}
+ cache-from: type=gha
+ cache-to: type=gha,mode=max
+ outputs: type=image,name=${{ steps.image.outputs.name }},push-by-digest=true,name-canonical=true,push=true
+
+ - name: 导出 digest
+ run: |
+ mkdir -p "${{ runner.temp }}/digests"
+ digest="${{ steps.build.outputs.digest }}"
+ touch "${{ runner.temp }}/digests/${digest#sha256:}"
+
+ - name: 上传 digest
+ uses: actions/upload-artifact@v4
+ with:
+ name: digests-${{ matrix.platform == 'linux/amd64' && 'amd64' || 'arm64' }}
+ path: ${{ runner.temp }}/digests/*
+ if-no-files-found: error
+ retention-days: 1
+
+ merge:
+ needs: build
+ runs-on: ubuntu-latest
+ steps:
+ - name: 下载各架构 digest
+ uses: actions/download-artifact@v4
+ with:
+ path: ${{ runner.temp }}/digests
+ pattern: digests-*
+ merge-multiple: true
+
+ - name: 计算镜像名
+ id: image
+ run: echo "name=${REGISTRY}/${GITHUB_REPOSITORY,,}" >> "$GITHUB_OUTPUT"
+
+ - uses: docker/setup-buildx-action@v3
+
+ - uses: docker/login-action@v3
+ with:
+ registry: ${{ env.REGISTRY }}
+ username: ${{ github.actor }}
+ password: ${{ secrets.GITHUB_TOKEN }}
+
- id: meta
uses: docker/metadata-action@v5
with:
@@ -77,8 +141,8 @@ jobs:
with:
context: .
platforms: linux/amd64,linux/arm64
- push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- cache-from: type=gha
- cache-to: type=gha,mode=max
+ annotations: ${{ steps.meta.outputs.annotations }}
+ provenance: mode=max
+ push: true