Skip to content

Commit ff7f8f0

Browse files
authored
Support multi-arch builds in the devcontainer (#43)
Make WASI SDK and Wasmtime work under x86-64 and arm64.
1 parent 817a84b commit ff7f8f0

File tree

2 files changed

+34
-10
lines changed

2 files changed

+34
-10
lines changed

.github/workflows/ci.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,12 @@ on:
99

1010
jobs:
1111
build_devcontainer:
12-
name: Build (Devcontainer)
13-
runs-on: ubuntu-latest
12+
name: Build and test (Devcontainer)
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
os: [ubuntu-latest, ubuntu-24.04-arm]
17+
runs-on: ${{ matrix.os }}
1418
env:
1519
TAG: cpython-devcontainer:1.0.0-${{ github.run_id }}
1620
steps:
@@ -24,6 +28,10 @@ jobs:
2428
context: ./devcontainer
2529
load: true
2630
tags: ${{ env.TAG }}
31+
- name: Test WASI SDK
32+
run: docker run --rm ${{ env.TAG }} /opt/wasi-sdk/bin/clang --version
33+
- name: Test Wasmtime
34+
run: docker run --rm ${{ env.TAG }} /usr/local/bin/wasmtime --version
2735

2836
build_autoconf:
2937
name: Build and test (Autoconf)

devcontainer/Dockerfile

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
FROM docker.io/library/fedora:41
22

3-
ENV CC=clang
3+
ARG TARGETARCH
44

5-
ENV WASI_SDK_VERSION=24
6-
ENV WASI_SDK_PATH=/opt/wasi-sdk
75

8-
ENV WASMTIME_HOME=/opt/wasmtime
9-
ENV WASMTIME_VERSION=22.0.0
10-
ENV WASMTIME_CPU_ARCH=x86_64
6+
ENV CC=clang
117

128
RUN dnf -y --nodocs --setopt=install_weak_deps=False --disablerepo=fedora-cisco-openh264 install \
139
/usr/bin/{blurb,clang,curl,git,ln,tar,xz} \
@@ -19,12 +15,32 @@ RUN dnf -y --nodocs --setopt=install_weak_deps=False --disablerepo=fedora-cisco-
1915
builddep python3 && \
2016
dnf -y clean all
2117

18+
19+
# Update only after consulting with WASI support maintainers (see PEP 11).
20+
ENV WASI_SDK_VERSION=24
21+
ENV WASI_SDK_PATH=/opt/wasi-sdk
22+
2223
RUN mkdir ${WASI_SDK_PATH} && \
23-
curl --location https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_SDK_VERSION}/wasi-sdk-${WASI_SDK_VERSION}.0-x86_64-linux.tar.gz | \
24+
case "${TARGETARCH}" in \
25+
amd64) WASI_ARCH="x86_64" ;; \
26+
arm64) WASI_ARCH="arm64" ;; \
27+
*) echo "Unsupported TARGETARCH: ${TARGETARCH}" && exit 1 ;; \
28+
esac && \
29+
curl --location https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_SDK_VERSION}/wasi-sdk-${WASI_SDK_VERSION}.0-${WASI_ARCH}-linux.tar.gz | \
2430
tar --strip-components 1 --directory ${WASI_SDK_PATH} --extract --gunzip
2531

32+
33+
# Update as desired.
34+
ENV WASMTIME_VERSION=33.0.0
35+
ENV WASMTIME_HOME=/opt/wasmtime
36+
2637
RUN mkdir --parents ${WASMTIME_HOME} && \
27-
curl --location "https://github.com/bytecodealliance/wasmtime/releases/download/v${WASMTIME_VERSION}/wasmtime-v${WASMTIME_VERSION}-${WASMTIME_CPU_ARCH}-linux.tar.xz" | \
38+
case "${TARGETARCH}" in \
39+
amd64) WASMTIME_ARCH="x86_64" ;; \
40+
arm64) WASMTIME_ARCH="aarch64" ;; \
41+
*) echo "Unsupported TARGETARCH: ${TARGETARCH}" && exit 1 ;; \
42+
esac && \
43+
curl --location "https://github.com/bytecodealliance/wasmtime/releases/download/v${WASMTIME_VERSION}/wasmtime-v${WASMTIME_VERSION}-${WASMTIME_ARCH}-linux.tar.xz" | \
2844
xz --decompress | \
2945
tar --strip-components 1 --directory ${WASMTIME_HOME} -x && \
3046
ln -s ${WASMTIME_HOME}/wasmtime /usr/local/bin

0 commit comments

Comments
 (0)