Skip to content

Commit

Permalink
Merge pull request #310 from PovilasID/patch-1
Browse files Browse the repository at this point in the history
Adding docker image for ARM
  • Loading branch information
valeriansaliou authored Dec 14, 2023
2 parents f18ea73 + c8c4bfb commit 969b1b7
Showing 1 changed file with 65 additions and 5 deletions.
70 changes: 65 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,22 @@ jobs:

build-docker:
runs-on: ubuntu-latest
strategy:
matrix:
platform:
- linux/arm64
- linux/amd64

steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v2
if: ${{ matrix.platform != 'linux/amd64' }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Acquire Docker image metadata
id: metadata
Expand All @@ -93,10 +105,58 @@ jobs:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push Docker image
uses: docker/build-push-action@v3
- name: Build and push by digest
uses: docker/build-push-action@v4
id: build
with:
context: .
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}
push: true
platforms: ${{ matrix.platform }}
outputs: type=image,name=valeriansaliou/sonic,push-by-digest=true,name-canonical=true,push=true

- name: Export digests
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
- name: Upload digests
uses: actions/upload-artifact@v3
with:
name: docker-digests
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1

merge-docker:
runs-on: ubuntu-latest
needs:
- build-docker

steps:
- name: Download digests
uses: actions/download-artifact@v3
with:
name: docker-digests
path: /tmp/digests

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: valeriansaliou/sonic

- name: Create manifest list and push
working-directory: /tmp/digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf 'valeriansaliou/sonic@sha256:%s ' *)

0 comments on commit 969b1b7

Please sign in to comment.