Support multi-arch docker image #55
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
| name: Docker-ARM | |
| on: [push, pull_request, workflow_dispatch] | |
| env: | |
| IMAGE_NAME: wine | |
| DOCKER_USERNAME: ${{ vars.DOCKER_USERNAME || 'zixia' }} | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| # This is used to complete the identity challenge | |
| # with sigstore/fulcio when running outside of PRs. | |
| id-token: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Docker Setup QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log into registry | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ env.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PERSONAL_ACCESS_TOKEN }} | |
| - name: Build and push Docker image (arm) | |
| run: | | |
| docker build --platform linux/arm64 -f Dockerfile.arm -t ${{ env.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}:arm64 --push . | |
| - name: Merge Multi-Arch Docker image | |
| run: | | |
| IMAGE=${{ env.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }} | |
| # 获取 digest | |
| AMD_DIGEST=$(docker buildx imagetools inspect $IMAGE:0.4 | grep '^Digest:' | awk '{print $2}') | |
| ARM_DIGEST=$(docker buildx imagetools inspect $IMAGE:arm64 | grep '^Digest:' | awk '{print $2}') | |
| echo "Got AMD digest: $AMD_DIGEST" | |
| echo "Got ARM digest: $ARM_DIGEST" | |
| # 创建并推送 manifest | |
| docker manifest create $IMAGE:latest \ | |
| $IMAGE@$AMD_DIGEST \ | |
| $IMAGE@$ARM_DIGEST | |
| docker manifest push $IMAGE:latest | |