Skip to content

Commit c18d010

Browse files
authored
fix(gha): QEMU and binfmt to build on non-native architectures (#1412)
Previously, the linux/s390x build would fail to install Podman if Podman was not yet in the GitHub Actions cache. Generalize the non-native architecture build process by using `tonistiigi/binfmt` to install QEMU handlers. This enables building container images for `linux/s390x` and `linux/ppc64le` on amd64 runners. The podman installation step is now also performed for these new platforms. This replaces the previous approach that used `docker/setup-qemu-action` and only supported `s390x`.
1 parent 2d7b24d commit c18d010

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

.github/workflows/build-notebooks-TEMPLATE.yaml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,13 @@ jobs:
6868
with:
6969
ref: "refs/pull/${{ fromJson(inputs.github).event.number }}/merge"
7070

71-
- name: Set up QEMU to build linux/s390x
72-
if: ${{ inputs.platform == 'linux/s390x' }}
73-
uses: docker/setup-qemu-action@v3
74-
with:
75-
platforms: s390x
71+
# https://github.com/docker/setup-qemu-action?tab=readme-ov-file#about
72+
# https://www.itix.fr/blog/qemu-user-static-with-podman/
73+
- name: Set up QEMU for non-native architecture
74+
if: ${{ contains(fromJSON('["linux/s390x", "linux/ppc64le"]'), inputs.platform) }}
75+
run: docker run --rm --privileged tonistiigi/binfmt --install ${platform#*/}
76+
env:
77+
platform: ${{ inputs.platform }}
7678

7779
- run: mkdir -p $TMPDIR
7880

@@ -175,8 +177,8 @@ jobs:
175177
path: /home/linuxbrew/.linuxbrew
176178
key: linuxbrew-${{ runner.os }}-${{ runner.arch }}
177179

178-
- name: Install podman (linux/amd64)
179-
if: inputs.platform == 'linux/amd64' && steps.cached-linuxbrew.outputs.cache-hit != 'true'
180+
- name: Install podman (linux/amd64, or qemu-user emulation)
181+
if: contains(fromJSON('["linux/amd64", "linux/s390x", "linux/ppc64le"]'), inputs.platform) && steps.cached-linuxbrew.outputs.cache-hit != 'true'
180182
run: |
181183
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
182184
/home/linuxbrew/.linuxbrew/bin/brew install podman

0 commit comments

Comments
 (0)