This repository contains a Web Assembly System Interface ("WASI") and Component Model enabled WebAssembly component example of a Golang (in this case TinyGo), built to run on wasmCloud.
Warning The WASI & the Component Model specifications are still undergoing changes and iterating quickly, so support inside wasmCloud is functional, but experimental.
You may see the mention of things like "preview2" or "preview3" -- these represent phases of the in-progress specification, standardization, and implementation efforts which could cause breaking changes.
Put on your cowboy hat ( 🤠 ) and enjoy the ride. File issues if/when it gets bumpy.
Before starting, ensure that you have the following installed:
- The TinyGo toolchain
wash
, the WAsmcloud SHell installed.
Once you have these two things, build the project locally:
wash build
After the project, you'll have a couple new folders, most importantly the build
folder:
build
├── http-echo-tinygo-component_s.wasm
└── http-echo-tinygo-component.wasm
build/http-echo-tinygo-component_s.wasm
is the WebAssembly module, signed with it's required capabilities, and ready to run on a wasmCloud lattice.
Start wasmCloud, in a separate terminal:
wash up --nats-websocket-port 4223
Warning This demo works with [
wasmCloud
host versions 0.81.0 or newer][host-v0.81.0].
Optionally, you can also start the UI by running (in a separate terminal):
wash ui
We can deploy the local project using the wasmCloud declarative deployment engine, wadm
.
First, edit wadm.yaml
to include the absolute path to the signed WebAssembly module:
# ....
components:
- name: http-echo-tinygo
type: component
properties:
- # TODO: you must replace the path below to match your genreated code in build
- image: file:///absolute/path/to/this/repo/build/http-echo-tinygo_s.wasm
+ image: file:///the/absolute/path/to/build/http-echo-tinygo-component_s.wasm
traits:
# ...
Then, deploy using wash
:
wash app deploy --replace wadm.yaml
You can use wash app
subcommand to do much more -- checking the list of applications, delete applications, and more.
For example, if you'd like to remove the previously deployed version of this project:
wash app delete http-echo-tinygo-component v0.0.1
To run tests for this example:
cd tests
go test -tags e2e
Information Note that the tests use
go
, nottinygo
, and requirewash
to be installed