Build arm64 Docker image (#115) #2
Workflow file for this run
This file contains 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: Create and publish a multi-architecture Docker image | |
on: | |
push: | |
tags: ['v[0-9]+.[0-9]+.[0-9]+'] | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ghcr.io/${{ github.repository }} | |
jobs: | |
build-image: | |
strategy: | |
fail-fast: false | |
matrix: | |
runner: [ubuntu-latest, buildjet-4vcpu-ubuntu-2204-arm] | |
runs-on: ${{ matrix.runner }} | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.IMAGE_NAME }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to the Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and export the image to Docker | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
load: true | |
tags: ${{ env.IMAGE_NAME }}:test | |
- name: Test the image | |
run: | | |
docker run --rm -i ${{ env.IMAGE_NAME }}:test < examples/nfldb.er >| nfldb.pdf | |
- name: Push the image by digest | |
id: build | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
labels: ${{ steps.meta.outputs.labels }} | |
outputs: type=image,name=${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true | |
- name: Export the digest | |
run: | | |
mkdir -p /tmp/digests | |
digest="${{ steps.build.outputs.digest }}" | |
touch "/tmp/digests/${digest#sha256:}" | |
- name: Upload the digest | |
uses: actions/upload-artifact@v3 | |
with: | |
name: digests | |
path: /tmp/digests/* | |
if-no-files-found: error | |
retention-days: 1 | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: example-diagram-nfldb | |
path: nfldb.pdf | |
merge-image: | |
runs-on: ubuntu-latest | |
needs: | |
- build-image | |
steps: | |
- name: Download digests | |
uses: actions/download-artifact@v3 | |
with: | |
name: digests | |
path: /tmp/digests | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.IMAGE_NAME }} | |
- name: Login to the Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- 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 '${{ env.IMAGE_NAME }}@sha256:%s ' *) | |
- name: Inspect image | |
run: | | |
docker buildx imagetools inspect ${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.version }} |