feat(ci): Build multi-arch Docker images (amd64, arm64) (#496)

* build ARM images
* Fix GH API rate limits
* `docker buildx` currently does not support `load` and multi-arch at the same time. 
  And used Github Action does not support output=type=oci

---------

Co-authored-by: Maksym Vlasov <MaxymVlasov@users.noreply.github.com>
Co-authored-by: George L. Yermulnik <yz@yz.kiev.ua>
This commit is contained in:
Scott Miller 2023-04-28 12:53:31 -04:00 committed by GitHub
commit 923c2c6a1e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 75 additions and 28 deletions

View file

@ -22,6 +22,9 @@ jobs:
.dockerignore
tools/entrypoint.sh
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@4b4e9c3e2d4531116a6f8ba8e71fc6e2cb6e6c8c # v2.5.0
- name: Build if Dockerfile changed
if: steps.changed-files-specific.outputs.any_changed == 'true'
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 # v4.0.0
@ -29,10 +32,15 @@ jobs:
context: .
build-args: |
INSTALL_ALL=true
platforms: linux/amd64
platforms: linux/amd64 # Only one allowed here, see https://github.com/docker/buildx/issues/59#issuecomment-1433097926
push: false
load: true
tags: |
ghcr.io/${{ github.repository }}:${{ env.IMAGE_TAG }}
# Fix multi-platform: https://github.com/docker/buildx/issues/1533
provenance: false
secrets: |
"github_token=${{ secrets.GITHUB_TOKEN }}"
- name: Run structure tests
if: steps.changed-files-specific.outputs.any_changed == 'true'
@ -48,3 +56,21 @@ jobs:
image: ghcr.io/${{ github.repository }}:${{ env.IMAGE_TAG }}
config-file: ${{ github.workspace }}/.github/.dive-ci.yaml
github-token: ${{ secrets.GITHUB_TOKEN }}
# Can't build both platforms and use --load at the same time
# https://github.com/docker/buildx/issues/59#issuecomment-1433097926
- name: Build Multi-arch docker-image
if: steps.changed-files-specific.outputs.any_changed == 'true'
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 # v4.0.0
with:
context: .
build-args: |
INSTALL_ALL=true
platforms: linux/amd64,linux/arm64
push: false
tags: |
ghcr.io/${{ github.repository }}:${{ env.IMAGE_TAG }}
# Fix multi-platform: https://github.com/docker/buildx/issues/1533
provenance: false
secrets: |
"github_token=${{ secrets.GITHUB_TOKEN }}"

View file

@ -27,6 +27,10 @@ jobs:
- name: Set tag for image
run: |
echo IMAGE_TAG=$([ ${{ github.ref_type }} == 'tag' ] && echo ${{ github.ref_name }} || echo 'latest') >> $GITHUB_ENV
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@4b4e9c3e2d4531116a6f8ba8e71fc6e2cb6e6c8c # v2.5.0
- name: Build and Push release
if: github.event_name != 'schedule'
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 # v4.0.0
@ -34,11 +38,16 @@ jobs:
context: .
build-args: |
INSTALL_ALL=true
platforms: linux/amd64
platforms: linux/amd64,linux/arm64
push: true
tags: |
ghcr.io/${{ github.repository }}:${{ env.IMAGE_TAG }}
ghcr.io/${{ github.repository }}:latest
# Fix multi-platform: https://github.com/docker/buildx/issues/1533
provenance: false
secrets: |
"github_token=${{ secrets.GITHUB_TOKEN }}"
- name: Build and Push nightly
if: github.event_name == 'schedule'
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 # v4.0.0
@ -46,7 +55,11 @@ jobs:
context: .
build-args: |
INSTALL_ALL=true
platforms: linux/amd64
platforms: linux/amd64,linux/arm64
push: true
tags: |
ghcr.io/${{ github.repository }}:nightly
# Fix multi-platform: https://github.com/docker/buildx/issues/1533
provenance: false
secrets: |
"github_token=${{ secrets.GITHUB_TOKEN }}"