Skip to content

Latest commit

 

History

History
74 lines (50 loc) · 2.61 KB

README.md

File metadata and controls

74 lines (50 loc) · 2.61 KB

WASI

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.

Reason

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.

Prereqs

brew install wasmtime

# ContainerD needs to be enabled (check for runc). 
docker info 

Run

# build wasm from assemblyscript
npm run asbuild:debug -- --use abort=assembly/index/myAbort

# start locally using wasmtime
npm run start

Docker

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

Created

# using asinit we create a template
npm install -g assemblyscript

./node_modules/.bin/asinit 86_wasi

Resources

  • 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