Files
gitea-actions/docker/multi-runner.yaml
imbytecat 566b80952a chore: 添加多架构Docker构建支持
- 添加多架构构建和合成manifest以支持生成不同平台的Docker镜像。
2025-06-28 15:04:40 +08:00

72 lines
1.7 KiB
YAML
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.
# 多机构建需要合成 manifest不然后提交的 docker 镜像会覆盖前面的
on:
workflow_dispatch:
env:
DOCKER_REGISTRY: git.furtherverse.com
IMAGE_NAME: ${{ github.repository }}
.docker-setup-buildx: &docker-setup-buildx
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
.docker-login: &docker-login
name: Login to Docker Registry
uses: docker/login-action@v3
with:
registry: ${{ env.DOCKER_REGISTRY }}
username: ${{ secrets.DOCKER_REGISTRY_USERNAME }}
password: ${{ secrets.DOCKER_REGISTRY_PASSWORD }}
.build-template: &build-template
steps:
- name: Checkout code
uses: actions/checkout@v4
- <<: *docker-setup-buildx
- <<: *docker-login
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
file: docker/Dockerfile
push: true
tags: ${{ env.DOCKER_REGISTRY }}/${{ env.IMAGE_NAME }}:latest-${{ env.ARCH }}
jobs:
build-amd64:
name: Build for AMD64
runs-on: ubuntu-latest-amd64
env:
ARCH: amd64
<<: *build-template
build-arm64:
name: Build for ARM64
runs-on: ubuntu-latest-arm64
env:
ARCH: arm64
<<: *build-template
create-manifest:
name: Create Image Manifest
runs-on: ubuntu-latest
needs:
- build-amd64
- build-arm64
steps:
- <<: *docker-setup-buildx
- <<: *docker-login
- name: Create manifest
uses: int128/docker-manifest-create-action@v2
with:
tags: ${{ env.DOCKER_REGISTRY }}/${{ env.IMAGE_NAME }}:latest
sources: |
${{ env.DOCKER_REGISTRY }}/${{ env.IMAGE_NAME }}:latest-amd64
${{ env.DOCKER_REGISTRY }}/${{ env.IMAGE_NAME }}:latest-arm64