Skip to content

Commit b66e2b1

Browse files
committed
Share more code between wasi images
1 parent a77e201 commit b66e2b1

File tree

3 files changed

+33
-44
lines changed

3 files changed

+33
-44
lines changed

ci/docker/wasm32-wasip1/Dockerfile

+3-22
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,7 @@
11
FROM ubuntu:24.04
22

3-
RUN apt-get update && \
4-
apt-get install -y --no-install-recommends \
5-
ca-certificates \
6-
curl \
7-
clang \
8-
xz-utils
9-
10-
# Wasmtime is used to execute tests and wasi-sdk is used to compile tests.
11-
# Download appropriate versions here and configure various flags below.
12-
#
13-
# Note that these versions are kept in sync with the `wasm32-wasip2/Dockerfile`
14-
# as well.
15-
ENV WASMTIME 24.0.0
16-
ENV WASI_SDK 24
17-
18-
RUN curl -L https://github.com/bytecodealliance/wasmtime/releases/download/v$WASMTIME/wasmtime-v$WASMTIME-x86_64-linux.tar.xz | \
19-
tar xJf -
20-
ENV PATH=$PATH:/wasmtime-v$WASMTIME-x86_64-linux
21-
22-
RUN curl -LO https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$WASI_SDK/wasi-sdk-$WASI_SDK.0-x86_64-linux.deb
23-
RUN dpkg -i ./wasi-sdk-*.deb
3+
COPY wasi.sh /
4+
RUN bash /wasi.sh
245

256
# Note that `-D_WASI_EMULATED_PROCESS_CLOCKS` is used to enable access to
267
# clock-related defines even though they're emulated. Also note that the usage
@@ -32,4 +13,4 @@ ENV CARGO_TARGET_WASM32_WASIP1_RUNNER=wasmtime \
3213
CARGO_TARGET_WASM32_WASIP1_RUSTFLAGS="-lwasi-emulated-process-clocks -Ctarget-feature=-crt-static" \
3314
CC_wasm32_wasip1=/opt/wasi-sdk/bin/clang \
3415
CFLAGS_wasm32_wasip1=-D_WASI_EMULATED_PROCESS_CLOCKS \
35-
PATH=$PATH:/rust/bin
16+
PATH=$PATH:/rust/bin:/wasmtime

ci/docker/wasm32-wasip2/Dockerfile

+3-22
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,7 @@
11
FROM ubuntu:24.04
22

3-
RUN apt-get update && \
4-
apt-get install -y --no-install-recommends \
5-
ca-certificates \
6-
curl \
7-
clang \
8-
xz-utils
9-
10-
# Wasmtime is used to execute tests and wasi-sdk is used to compile tests.
11-
# Download appropriate versions here and configure various flags below.
12-
#
13-
# Note that these versions are kept in sync with the `wasm32-wasip2/Dockerfile`
14-
# as well.
15-
ENV WASMTIME 24.0.0
16-
ENV WASI_SDK 24
17-
18-
RUN curl -L https://github.com/bytecodealliance/wasmtime/releases/download/v$WASMTIME/wasmtime-v$WASMTIME-x86_64-linux.tar.xz | \
19-
tar xJf -
20-
ENV PATH=$PATH:/wasmtime-v$WASMTIME-x86_64-linux
21-
22-
RUN curl -LO https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$WASI_SDK/wasi-sdk-$WASI_SDK.0-x86_64-linux.deb
23-
RUN dpkg -i ./wasi-sdk-*.deb
3+
COPY wasi.sh /
4+
RUN bash /wasi.sh
245

256
# Note that most of these are copied from `wasm32-wasip1/Dockerfile`
267
#
@@ -31,4 +12,4 @@ ENV CARGO_TARGET_WASM32_WASIP2_RUNNER=wasmtime \
3112
CARGO_TARGET_WASM32_WASIP2_RUSTFLAGS="-lwasi-emulated-process-clocks -Ctarget-feature=-crt-static -Clink-arg=-Wl,--export,cabi_realloc" \
3213
CC_wasm32_wasip2=/opt/wasi-sdk/bin/clang \
3314
CFLAGS_wasm32_wasip2=-D_WASI_EMULATED_PROCESS_CLOCKS \
34-
PATH=$PATH:/rust/bin
15+
PATH=$PATH:/rust/bin:/wasmtime

ci/wasi.sh

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env bash
2+
3+
set -ex
4+
5+
apt-get update
6+
apt-get install -y --no-install-recommends \
7+
ca-certificates \
8+
curl \
9+
clang \
10+
xz-utils
11+
12+
# Wasmtime is used to execute tests and wasi-sdk is used to compile tests.
13+
# Download appropriate versions here and configure various flags below.
14+
#
15+
# At the time of this writing wasmtime 24.0.0 is the latest release and
16+
# wasi-sdk-24 is the latest release, that these numbers match is just
17+
# coincidence.
18+
wasmtime=24.0.0
19+
wasi_sdk=24
20+
21+
curl -L https://github.com/bytecodealliance/wasmtime/releases/download/v$wasmtime/wasmtime-v$wasmtime-x86_64-linux.tar.xz | \
22+
tar xJf -
23+
mv wasmtime-v$wasmtime-x86_64-linux wasmtime
24+
25+
# The pre-built `*.deb` files for wasi-sdk install to `/opt/wasi-sdk`
26+
curl -LO https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$wasi_sdk/wasi-sdk-$wasi_sdk.0-x86_64-linux.deb
27+
dpkg -i ./wasi-sdk-*.deb

0 commit comments

Comments
 (0)