Skip to content

Commit

Permalink
supports multi-arch image manifest
Browse files Browse the repository at this point in the history
Signed-off-by: cyclinder <qifeng.guo@daocloud.io>
  • Loading branch information
cyclinder committed Jan 3, 2023
1 parent 4146482 commit a8dd351
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 2 deletions.
33 changes: 32 additions & 1 deletion .github/workflows/image-push-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ jobs:
uses: docker/build-push-action@v2
with:
context: .
platforms: linux/amd64
push: true
tags: |
${{ env.IMAGE_NAME }}:latest
${{ env.IMAGE_NAME }}:latest-amd64
${{ env.IMAGE_NAME }}:${{ github.sha }}
file: images/Dockerfile
Expand Down Expand Up @@ -100,3 +100,34 @@ jobs:
tags: |
${{ env.IMAGE_NAME }}:latest-ppc64le
file: images/Dockerfile.ppc64le

push-manifest:
runs-on: ubuntu-20.04
env:
IMAGE_NAME: ghcr.io/${{ github.repository }}
needs: [build-and-push-amd64-device-plugin,build-and-push-arm64-device-plugin,build-and-push-ppc64le-device-plugin]
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Create manifest for multi-arch images
run: |
# pull
docker pull ${{ env.IMAGE_NAME }}:latest-amd64
docker pull ${{ env.IMAGE_NAME }}:latest-arm64
docker pull ${{ env.IMAGE_NAME }}:latest-ppc64le
# create
docker manifest create ${{ env.IMAGE_NAME }}:latest ${{ env.IMAGE_NAME }}:latest-amd64 ${{ env.IMAGE_NAME }}:latest-arm64 ${{ env.IMAGE_NAME }}:latest-ppc64le
# annotate
docker manifest annotate ${{ env.IMAGE_NAME }}:latest ${{ env.IMAGE_NAME }}:latest-amd64 --arch amd64
docker manifest annotate ${{ env.IMAGE_NAME }}:latest ${{ env.IMAGE_NAME }}:latest-arm64 --arch arm64
docker manifest annotate ${{ env.IMAGE_NAME }}:latest ${{ env.IMAGE_NAME }}:latest-ppc64le --arch ppc64le
# push
docker manifest push ${{ env.IMAGE_NAME }}:latest
39 changes: 38 additions & 1 deletion .github/workflows/image-push-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ jobs:
uses: docker/build-push-action@v2
with:
context: .
platforms: linux/amd64
push: true
tags: |
${{ steps.docker_meta.outputs.tags }}
${{ steps.docker_meta.outputs.tags }}-amd64
file: images/Dockerfile

build-and-push-arm64-device-plugin:
Expand Down Expand Up @@ -119,3 +120,39 @@ jobs:
tags: |
${{ steps.docker_meta.outputs.tags }}-ppc64le
file: images/Dockerfile.ppc64le

push-manifest:
runs-on: ubuntu-20.04
needs: [build-and-push-amd64-device-plugin,build-and-push-arm64-device-plugin,build-and-push-ppc64le-device-plugin]
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Docker meta
id: docker_meta
uses: crazy-max/ghaction-docker-meta@v1
with:
images: ${{ env.IMAGE_NAME }}
tag-latest: false

- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Create manifest for multi-arch images
run: |
# pull
docker pull ${{ steps.docker_meta.outputs.tags }}-amd64
docker pull ${{ steps.docker_meta.outputs.tags }}-arm64
docker pull ${{ steps.docker_meta.outputs.tags }}-ppc64le
# create
docker manifest create ${{ steps.docker_meta.outputs.tags }} ${{ steps.docker_meta.outputs.tags }}-amd64 ${{ steps.docker_meta.outputs.tags }}-arm64 ${{ steps.docker_meta.outputs.tags }}-ppc64le
# annotate
docker manifest annotate ${{ steps.docker_meta.outputs.tags }} ${{ steps.docker_meta.outputs.tags }}-amd64 --arch amd64
docker manifest annotate ${{ steps.docker_meta.outputs.tags }} ${{ steps.docker_meta.outputs.tags }}-arm64 --arch arm64
docker manifest annotate ${{ steps.docker_meta.outputs.tags }} ${{ steps.docker_meta.outputs.tags }}-ppc64le --arch ppc64le
# push
docker manifest push ${{ steps.docker_meta.outputs.tags }}

0 comments on commit a8dd351

Please sign in to comment.