Demonstrate how to setup a WASI based container.
TODO:
- How do I pass dir to docker
wasmtime --dir . ./build/debug.wasm
NOTES:
- This only runs on docker with
containerd
activated.
Using WASM allows us to run small containers on multiple architectures.
One of the benefits of using Wasm containers is that they provide a secure and isolated environment for running code. Because Wasm code is executed in a sandboxed environment, it is protected from the rest of the system and cannot access resources or data outside of its sandbox. This can help prevent malicious code from causing damage to the host system or stealing sensitive information.
brew install wasmtime
# ContainerD needs to be enabled (check for runc).
docker info
# build wasm from assemblyscript
npm run asbuild:debug -- --use abort=assembly/index/myAbort
# start locally using wasmtime
npm run start
NOTE: The challenge of building in a container is that we need to switch architectures during the build.
# build using local files
npm run docker:build
# build in a container
npm run docker:buildwasm
npm run docker:start
# using asinit we create a template
npm install -g assemblyscript
./node_modules/.bin/asinit 86_wasi
- WASM Docker Desktop here
- WASMTime here
- Getting started with Docker + Wasm here
- WebAssembly System Interface (WASI) Node here
- The AssemblyScript Book Examples here
- WASM by Example WASI Hello World here
- A high-level AssemblyScript layer for the WebAssembly System Interface (WASI) here
- WasmEdge is a lightweight, high-performance, and extensible WebAssembly runtime. here
- as-wasi fails to build with v0.20.0 #2259 here
- Importing the correct Wasi module in node.js here
- Stand-Alone WebAssembly Runtime Support? #967 here
- can't pull images while building with buildx 'failed to do request', 'i/o timeout' #191 here