Skip to content

Commit 22a9c79

Browse files
committed
Move devcontainer installation to shell scripts
This makes the installation more reusable, avoids backslash line continuation, and allows inline comments in more places.
1 parent c1c9c12 commit 22a9c79

File tree

3 files changed

+64
-31
lines changed

3 files changed

+64
-31
lines changed

devcontainer/Dockerfile

Lines changed: 7 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,47 +2,23 @@ FROM docker.io/library/fedora:41
22

33
ARG TARGETARCH
44

5-
65
ENV CC=clang
76

8-
RUN dnf -y --nodocs --setopt=install_weak_deps=False --disablerepo=fedora-cisco-openh264 install \
9-
/usr/bin/{blurb,clang,curl,git,ln,tar,xz} \
10-
compiler-rt \
11-
# TODO: remove when Fedora version includes Python 3.14+
12-
libzstd-devel \
13-
'dnf5-command(builddep)' && \
14-
dnf -y --nodocs --setopt=install_weak_deps=False --disablerepo=fedora-cisco-openh264 \
15-
builddep python3 && \
16-
dnf -y clean all
17-
7+
# Remove a video codec repository to speed up installs
8+
RUN dnf config-manager setopt fedora-cisco-openh264.enabled=False
189

1910
# Update only after consulting with WASI support maintainers (see PEP 11).
2011
ENV WASI_SDK_VERSION=24
2112
ENV WASI_SDK_PATH=/opt/wasi-sdk
2213

23-
RUN mkdir ${WASI_SDK_PATH} && \
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 | \
30-
tar --strip-components 1 --directory ${WASI_SDK_PATH} --extract --gunzip
31-
32-
3314
# Update as desired.
3415
ENV WASMTIME_VERSION=33.0.0
3516
ENV WASMTIME_HOME=/opt/wasmtime
3617

37-
RUN mkdir --parents ${WASMTIME_HOME} && \
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" | \
44-
xz --decompress | \
45-
tar --strip-components 1 --directory ${WASMTIME_HOME} -x && \
46-
ln -s ${WASMTIME_HOME}/wasmtime /usr/local/bin
4718

19+
RUN mkdir -p /opt/cpython-devcontainer/bin
20+
COPY --chmod=755 install-builddeps.sh install-wasi.sh /opt/cpython-devcontainer/bin/
21+
RUN chmod +x /opt/cpython-devcontainer/bin/install-*.sh
4822

23+
RUN /opt/cpython-devcontainer/bin/install-builddeps.sh
24+
RUN /opt/cpython-devcontainer/bin/install-wasi.sh

devcontainer/install-builddeps.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#! /bin/bash -ex
2+
3+
# Install build tools and CPython dependencies on Fedora.
4+
5+
6+
# Define dependencies as an array, for easier formatting & comments.
7+
# see: https://www.gnu.org/software/bash/manual/html_node/Arrays.html
8+
DEPS=(
9+
/usr/bin/{blurb,clang,curl,git,ln,tar,xz}
10+
'dnf5-command(builddep)'
11+
12+
# LLVM sanitizer runtimes
13+
compiler-rt
14+
15+
# TODO: remove when Fedora version includes Python 3.14
16+
libzstd-devel
17+
)
18+
19+
dnf -y --nodocs --setopt=install_weak_deps=False install ${DEPS[@]}
20+
dnf -y --nodocs --setopt=install_weak_deps=False builddep python3
21+
22+
# Don't leave caches in the container
23+
dnf -y clean all

devcontainer/install-wasi.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#! /bin/bash -ex
2+
3+
# Install the WASI SDK.
4+
# This should be portable to any Linux, but is only tested in the devcontainer.
5+
6+
7+
mkdir ${WASI_SDK_PATH}
8+
9+
case "${TARGETARCH}" in
10+
amd64) WASI_ARCH="x86_64" ;;
11+
arm64) WASI_ARCH="arm64" ;;
12+
*) echo "Unsupported TARGETARCH: ${TARGETARCH}" && exit 1 ;;
13+
esac && \
14+
15+
URL=https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_SDK_VERSION}/wasi-sdk-${WASI_SDK_VERSION}.0-${WASI_ARCH}-linux.tar.gz
16+
17+
curl --location $URL | tar --strip-components 1 --directory ${WASI_SDK_PATH} --extract --gunzip
18+
19+
20+
mkdir --parents ${WASMTIME_HOME}
21+
22+
case "${TARGETARCH}" in
23+
amd64) WASMTIME_ARCH="x86_64" ;;
24+
arm64) WASMTIME_ARCH="aarch64" ;;
25+
*) echo "Unsupported TARGETARCH: ${TARGETARCH}" && exit 1 ;;
26+
esac
27+
28+
URL="https://github.com/bytecodealliance/wasmtime/releases/download/v${WASMTIME_VERSION}/wasmtime-v${WASMTIME_VERSION}-${WASMTIME_ARCH}-linux.tar.xz"
29+
30+
curl --location $URL |
31+
xz --decompress |
32+
tar --strip-components 1 --directory ${WASMTIME_HOME} -x
33+
34+
ln -s ${WASMTIME_HOME}/wasmtime /usr/local/bin

0 commit comments

Comments
 (0)