A collection showcasing how to generate WASM from various programming languages and execute the WASM code using a WASM runtime.
NOTE: HTTP services might be hard to compile since socket support might not yet be available in Wasi. Therefore search in following link for socket support
. Optionally check further projects:
- runwasi - Facilitates running Wasm / WASI workloads managed by containerd
- spin - Spin is the open source developer tool for building and running serverless applications powered by WebAssembly.
- Compile Rust & Go to a Wasm+Wasi module and run in a Wasm runtime
- wasmer Github repo
- wasmtime Github repo
Run following commands:
cd samples/simple-rust
# when wanting to utilize wasmer as WebAssembly runtime
docker build -t simple-rust-wasm-app-with-wasmer:stable -f Dockerfile.wasmer .
docker run --rm simple-rust-wasm-app-with-wasmer:stable bash -c "wasmer run simple-rust.wasm"
# when wanting to utilize wasmtime as WebAssembly runtime
docker build -t simple-rust-wasm-app-with-wasmtime:stable -f Dockerfile.wasmtime .
docker run --rm simple-rust-wasm-app-with-wasmtime:stable bash -c "wasmtime run simple-rust.wasm"
Run following commands:
cd samples/simple-go
docker build -t simple-go-wasm-app-with-wasmtime:stable .
docker run --rm simple-go-wasm-app-with-wasmtime:stable bash -c "wasmtime run output.wasm"
Run following commands to spin up a serverless application powered by WebAssembly:
cd samples/simple-rust-service
# Update in the `spin.toml` the cargo command
spin build # Build WebAssembly file
spin up # Run serverless HTTP service powered by WebAssembly
NOTE: Spin was installed in and utilized with Ubuntu WSL