diff options
author | Andrew Clayton <a.clayton@nginx.com> | 2023-08-02 17:03:48 +0100 |
---|---|---|
committer | Andrew Clayton <a.clayton@nginx.com> | 2023-08-21 23:24:12 +0100 |
commit | d6ed6a219b31a58526721f96195c80061d41ce54 (patch) | |
tree | 17a1fd6ecf72a327916ff0f8bc7aaf85b981ceff /examples/docker/unit-wasm.Dockerfile | |
download | unit-wasm-c43c6b57d70ae3a2cb3a52f5f991cd68fd39b47d.tar.gz unit-wasm-c43c6b57d70ae3a2cb3a52f5f991cd68fd39b47d.tar.bz2 |
Initial commitv0.1.0
libunit-wasm and example C and Rust WebAssembly modules for NGINX Unit.
Co-developed-by: Timo Stark <t.stark@nginx.com>
Co-developed-by: Liam Crilly <liam@nginx.com>
Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
Diffstat (limited to 'examples/docker/unit-wasm.Dockerfile')
-rw-r--r-- | examples/docker/unit-wasm.Dockerfile | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/examples/docker/unit-wasm.Dockerfile b/examples/docker/unit-wasm.Dockerfile new file mode 100644 index 0000000..b7b47a5 --- /dev/null +++ b/examples/docker/unit-wasm.Dockerfile @@ -0,0 +1,40 @@ +# Start with the minimal Docker Official Image so we can use the same defaults +# +FROM unit:minimal AS build +WORKDIR /src + +# Get all the build tools we need, including Wasmtime +# +#RUN apt update && apt install -y wget git build-essential clang lld libpcre2-dev libssl-dev +RUN apt update && apt install -y wget git build-essential libpcre2-dev libssl-dev +RUN wget -O- https://github.com/bytecodealliance/wasmtime/releases/download/v11.0.0/wasmtime-v11.0.0-$(arch)-linux-c-api.tar.xz \ + | tar Jxfv - && \ + mkdir /usr/lib/wasmtime && \ + cp /src/wasmtime-v11.0.0-$(arch)-linux-c-api/lib/* /usr/lib/wasmtime + +# Build NGINX JavaScript (njs) so that we have a feature-complete Unit +# +RUN git clone https://github.com/nginx/njs.git && \ + cd njs && \ + ./configure --no-libxml2 --no-zlib && \ + make + +# Build Unit with the Wasm module, copying the configure arguments from the +# official image. +# +RUN git clone https://github.com/nginx/unit.git && \ + cd unit && \ + wget -O- https://github.com/nginx/unit/pull/902.patch | patch -p1 && \ + ./configure $(unitd --version 2>&1 | tr ' ' '\n' | grep ^-- | grep -v opt=) \ + --cc-opt="-I/src/njs/src -I/src/njs/build" --ld-opt=-L/src/njs/build && \ + ./configure wasm --include-path=/src/wasmtime-v11.0.0-$(arch)-linux-c-api/include \ + --lib-path=/usr/lib/wasmtime --rpath && \ + make + +# Create a clean final image by copying over only Wasmtime, the new unitd +# binary, and the Wasm module. +# +FROM unit:minimal +COPY --from=build /src/unit/build/sbin/unitd /usr/sbin +COPY --from=build /src/unit/build/lib/unit/modules/wasm.unit.so /usr/lib/unit/modules +COPY --from=build /usr/lib/wasmtime/*.so /usr/lib/wasmtime/ |