Skip to content

Commit

Permalink
Try to fix building multi-arch containers
Browse files Browse the repository at this point in the history
  • Loading branch information
yorickpeterse committed Jan 17, 2025
1 parent d90ade5 commit 529e000
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 42 deletions.
67 changes: 54 additions & 13 deletions .github/workflows/container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,22 @@ on:
description: 'The name of the image to build'
required: true
type: string
platform:
description: 'The Docker platform to build for'
required: false
type: string
default: linux/amd64
runner:
description: 'The GitHub runner to use'
required: false
type: string
default: ubuntu-24.04

env:
REGISTRY: ghcr.io
NAMESPACE: inko-lang/ci

jobs:
build:
runs-on: ${{ inputs.runner }}
name: ${{ inputs.name }}-${{ matrix.target.arch }} build
strategy:
matrix:
target:
- arch: amd64
runner: ubuntu-24.04
- arch: arm64
runner: ubuntu-24.04-arm
runs-on: ${{ matrix.target.runner }}
permissions:
contents: read
packages: write
Expand All @@ -35,9 +33,52 @@ jobs:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/build-push-action@v5
- uses: docker/setup-buildx-action@v3
- name: Build imaage
id: build
uses: docker/build-push-action@v5
with:
context: ci/docker/${{ inputs.name }}
platforms: ${{ inputs.platform }}
platforms: linux/${{ matrix.target.arch }}
push: true
tags: ${{ env.REGISTRY }}/${{ env.NAMESPACE }}:${{ inputs.name }}
outputs: type=image,name=${{ env.REGISTRY }}/${{ env.NAMESPACE }},push-by-digest=true,name-canonical=true,push=true
- name: Export digest
run: |
mkdir -p ${{ runner.temp }}/digests
digest="${{ steps.build.outputs.digest }}"
touch "${{ runner.temp }}/digests/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@v4
with:
name: digests-${{ inputs.name }}-${{ matrix.target.arch }}
path: ${{ runner.temp }}/digests/*
if-no-files-found: error
retention-days: 1

merge:
runs-on: ubuntu-24.04
needs:
- build
steps:
- name: Download digests
uses: actions/download-artifact@v4
with:
path: ${{ runner.temp }}/digests
pattern: digests-${{ inputs.name }}-*
merge-multiple: true
- uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/setup-buildx-action@v3
- uses: docker/metadata-action@v5
id: meta
with:
images: ${{ env.REGISTRY }}/${{ env.NAMESPACE }}
- name: Create and push manifest
working-directory: ${{ runner.temp }}/digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ env.REGISTRY }}/${{ env.NAMESPACE }}@sha256:%s ' *)
16 changes: 2 additions & 14 deletions .github/workflows/containers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,11 @@ jobs:
uses: ./.github/workflows/container.yml
with:
name: fedora
alpine-amd64:
alpine:
uses: ./.github/workflows/container.yml
with:
name: alpine
alpine-arm64:
uses: ./.github/workflows/container.yml
with:
name: alpine
runner: ubuntu-24.04-arm
platform: linux/arm64
debian-amd64:
uses: ./.github/workflows/container.yml
with:
name: debian
debian-arm64:
debian:
uses: ./.github/workflows/container.yml
with:
name: debian
runner: ubuntu-24.04-arm
platform: linux/arm64
10 changes: 5 additions & 5 deletions .github/workflows/runtimes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,22 @@ jobs:
matrix:
target:
- image: ci:debian
name: amd64-linux
arch: amd64
runner: ubuntu-24.04
- image: ci:debian
name: arm64-linux
arch: arm64
runner: ubuntu-24.04-arm
name: ${{ matrix.target.name }}
name: ${{ matrix.target.arch }}-linux
runs-on: ${{ matrix.target.runner }}
container:
image: ghcr.io/inko-lang/${{ matrix.target.image }}
steps:
- uses: actions/checkout@v4
- name: Build runtimes
run: bash ci/runtimes.sh ${{ matrix.target.name }}
run: bash ci/runtimes.sh ${{ matrix.target.arch }}-linux
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.target.name }}
name: ${{ matrix.target.arch }}-linux
path: tmp/runtimes/*.tar.gz
overwrite: true
retention-days: 2
Expand Down
28 changes: 18 additions & 10 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,23 +67,27 @@ jobs:
strategy:
matrix:
target:
- image: ci:debian
- image: debian
name: amd64-linux-gnu
platform: linux/amd64
runner: ubuntu-24.04
- image: ci:debian
- image: debian
name: arm64-linux-gnu
platform: linux/arm64
runner: ubuntu-24.04-arm
- image: ci:alpine
- image: alpine
name: amd64-linux-musl
platform: linux/amd64
runner: ubuntu-24.04
- image: ci:alpine
- image: alpine
name: arm64-linux-musl
platform: linux/arm64
runner: ubuntu-24.04-arm
name: ${{ matrix.target.name }} compiler
timeout-minutes: 15
runs-on: ${{ matrix.target.runner }}
container:
image: ghcr.io/inko-lang/${{ matrix.target.image }}
image: ghcr.io/inko-lang/ci:${{ matrix.target.image }}
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
Expand All @@ -101,23 +105,27 @@ jobs:
- balanced
- aggressive
target:
- image: ci:debian
- image: debian
name: amd64-linux-gnu
platform: linux/amd64
runner: ubuntu-24.04
- image: ci:alpine
- image: alpine
name: amd64-linux-musl
platform: linux/amd64
runner: ubuntu-24.04
- image: ci:debian
- image: debian
name: arm64-linux-gnu
platform: linux/arm64
runner: ubuntu-24.04-arm
- image: ci:alpine
- image: alpine
name: arm64-linux-musl
platform: linux/arm64
runner: ubuntu-24.04-arm
name: ${{ matrix.target.name }} std --opt=${{ matrix.level }}
timeout-minutes: 15
runs-on: ${{ matrix.target.runner }}
container:
image: ghcr.io/inko-lang/${{ matrix.target.image }}
image: ghcr.io/inko-lang/ci:${{ matrix.target.image }}
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
Expand Down

0 comments on commit 529e000

Please sign in to comment.