-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathDockerfile.wasi-builder
87 lines (80 loc) · 2.86 KB
/
Dockerfile.wasi-builder
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
ARG WABT_VERSION=1.0.32
# E.g. WASI_SDK_VERSION=20.0
ARG WASI_SDK_VERSION
# E.g. WASI_SDK_RELEASE_NAME=wasi-sdk-20
ARG WASI_SDK_RELEASE_NAME
# For beta releases with specific features this goes like:
# ARG WASI_SDK_VERSION=20.0.threads
# ARG WASI_SDK_RELEASE_NAME=wasi-sdk-20+threads
ARG WASI_VFS_VERSION=v0.4.0
ARG WASI_SDK_PATH=/wasi-sdk
ARG WASI_SDK_ASSET_NAME=wasi-sdk-${WASI_SDK_VERSION}
ARG WABT=wabt-${WABT_VERSION}
ARG WABT_ROOT=/wabt
ARG WASI_VFS_ROOT=/wasi-vfs
FROM ghcr.io/vmware-labs/wasmlabs/wasm-base:latest AS wasi-base
ARG WASI_SDK_ASSET_NAME
ARG WASI_SDK_RELEASE_NAME
ARG WASI_SDK_PATH
RUN apt update && \
DEBIAN_FRONTEND=noninteractive apt install -y \
autoconf \
automake \
build-essential \
cmake \
clang \
curl \
git \
jq \
libtool \
libtool-bin \
pkg-config \
tcl \
unzip
RUN wget https://github.com/WebAssembly/wasi-sdk/releases/download/${WASI_SDK_RELEASE_NAME}/${WASI_SDK_ASSET_NAME}-linux.tar.gz && \
mkdir ${WASI_SDK_PATH} && \
tar xf ${WASI_SDK_ASSET_NAME}-linux.tar.gz --strip-components=1 -C ${WASI_SDK_PATH} && \
rm ${WASI_SDK_ASSET_NAME}-linux.tar.gz
FROM docker.io/library/rust:1.67.1-slim AS builder-wasi-vfs
ARG WASI_SDK_PATH
ARG WASI_VFS_VERSION
COPY --from=wasi-base ${WASI_SDK_PATH} ${WASI_SDK_PATH}
RUN apt update && \
DEBIAN_FRONTEND=noninteractive apt install -y \
git
RUN git clone --recurse-submodules https://github.com/kateinoigakukun/wasi-vfs
RUN cd wasi-vfs && \
git checkout ${WASI_VFS_VERSION} && \
cargo build --release -p wasi-vfs-cli && \
cargo build --release --target=wasm32-unknown-unknown
FROM wasi-base
ARG WABT_VERSION
ARG WASI_SDK_ASSET_NAME
ARG WASI_SDK_PATH
ARG WASI_SDK_VERSION
ARG WASI_VFS_VERSION
ARG WABT
ARG WABT_ROOT
ARG WASI_VFS_ROOT
ENV WABT_VERSION=${WABT_VERSION}
ENV WASI_SDK_ASSET_NAME=${WASI_SDK_ASSET_NAME}
ENV WASI_SDK_PATH=${WASI_SDK_PATH}
ENV WASI_SDK_VERSION=${WASI_SDK_VERSION}
ENV WASI_VFS_VERSION=${WASI_VFS_VERSION}
# Keep WASI_SDK_ROOT for compatibility for a while
ENV WASI_SDK_ROOT=${WASI_SDK_PATH}
ENV WABT=${WABT}
ENV WABT_ROOT=${WABT_ROOT}
ENV WASI_VFS_ROOT=${WASI_VFS_ROOT}
RUN mkdir -p /wasi-vfs/bin /wasi-vfs/lib
COPY --from=builder-wasi-vfs /wasi-vfs/target/wasm32-unknown-unknown/release/libwasi_vfs.a /wasi-vfs/lib/
COPY --from=builder-wasi-vfs /wasi-vfs/target/release/wasi-vfs /wasi-vfs/bin/
RUN wget https://github.com/WebAssembly/wabt/releases/download/${WABT_VERSION}/${WABT}-ubuntu.tar.gz && \
mkdir ${WABT_ROOT} && \
tar xf ${WABT}-ubuntu.tar.gz --strip-components=1 -C ${WABT_ROOT} && \
rm ${WABT}-ubuntu.tar.gz
RUN mkdir /wlr
ENV PATH="$WASI_SDK_PATH/bin:$PATH:$WASI_VFS_ROOT/bin"
# We will be mounting the source repo in /wlr, which is owned by a user different from root.
RUN git config --global --add safe.directory /wlr
WORKDIR /wlr