Workflows
As a developer using wasmCloud, there are a number of common day-to-day workflows that you will experience.
The following is a list of developer workflows sorted from most to least common.
Building Components
The most common thing application developers will do is build components. Components encompass pure business logic in wasmCloud, and only communicate with non-functional requirements through capability providers and abstract interfaces.
Once you've established a dependency on a library that exposes the interface abstraction you're looking for, you can start your iteration loop.
The developer's iteration loop for building a component looks something like this:
- Make code changes
- Compile and sign the WebAssembly module, creating a
_s.wasmfile (usingwash buildin a component project) - Test the module
- In the CLI
- Use the
wash devcommand to automatically watch component files for changes - Script
wash callcommands to invoke the component - Modify your component code, run
wash buildto recompile and re-sign the component, repeat the above step
- Use the
- In the CLI
- Repeat
As of wash 0.18.0, there is now a wash dev command that automates this process for you. See the Customizing the component section for more details on how to use it.
Building Providers
The workflow for building a capability provider is similar to that of building a component. Once you've located and declared a dependency on the interface implemented by your capability provider, the iteration loop looks something like this:
- Make code changes
- Execute tests (
make test) - Compile native executable binary
- Create and sign JWT
- Embed JWT and executable in a
.par.gz(provider archive) file. (Steps 3-5 can be done with the single commandmakeusing the generated project Makefiles). - Publish
.PARfile to local or remote OCI registry (make push) - Test/Utilize the provider in the context of a host/lattice
- Repeat
Running a local OCI registry
While it isn't called out as a specific pre-requisite, many of the steps in the developer iteration loops involve interacting with an OCI registry. Unless you've got a public one that you can use, you'll likely want to use a local one for testing.
To start a local OCI registry, download the sample Docker Compose file into the current folder and run
docker compose up -d registryOnce it's running, you can push components and capability providers to the registry using wash push. For example:
wash push localhost:5000/my component:0.1.0 ./build/my_ component_s.wasm
wash push localhost:5000/myprovider:0.1.0 ./build/my_provider.par.gzThe wash reg push subcommand was renamed to wash push.
See the wash command ref componenting RFC for more information and to provide feedback
Allowing unauthenticated OCI registry access
The wasmCloud host runtime will, by default, require that all OCI references use authentication in order to resolve and download. This is a security measure that is enabled by default to keep the system as secure as possible.
However, if you're running the local docker-supplied registry with its default settings, that registry will not have any authentication requirements. If you want your wasmCloud host to be able to talk to this registry, you'll need to enable unauthenticated OCI registry access.
This can be done by setting the environment variable WASMCLOUD_OCI_ALLOWED_INSECURE to include the URL of your local registry, e.g. localhost:5000. You can either supply this as an environment variable directly when you start a local wasmCloud host via iex or the release binary, or you can modify your shell profile to always set this variable on your development workstation.
Purging the OCI cache
The wasmCloud host runtime caches the files that it receives from OCI registries beneath whatever temp directory your operating system prefers. Because images in an OCI registry are supposed to be immutable (another reason we recommend against using latest when requesting an image version), the wasmCloud host has no reason to automatically purge or overwrite these files in the cache.
During your local development iterations, you will likely find yourself pushing the same file with the same OCI reference over and over again. In order for the wasmCloud host to see these changes, you'll need to drain the wasmCloud host cache. This can be done by executing one of the variants of wash drain, such as wash drain all.
Testing wadm manifests faster with wash
As of wash v0.29.0, deploying applications and iterative development has become much easier with the help of a few new commands.
Validate wadm application manifests before deploying them
Misspelled interfaces, missing links, and other issues can be hard to find in a wadm application manifest.
To find potential issues before you wash app deploy your manifest, use wash app validate:
wash app validate path/to/your/wadm.yamlwash app validate will check for common issues and errors in your wadm manifest, and notify you of any issues.
Start a host and deploy a wadm application manifest in one command
The easiest way to test a wadm application is to start a host, deploy the application, and start using it.
To quickly run a host and deploy a single wadm manifest, run wash up with --wadm-manifest:
wash up --wadm-manifest path/to/your/wadm.yamlWhen run this way, wash up will start a single host lattice as normal, but also deploy your provided manifest to the running lattice, so you can interact with your application as soon as possible.
Easily deploy an application continuously
The recommended way to do local iterative development with fast feedback loops is wash dev.
In a wasmCloud project with a wasmcloud.toml file present, run the following:
wash devThis will start a local wasmCloud host, build your project, and react to changes to local code, redeploying your project as necessary.
Other ways to deploy a manually (deprecated)
While the methods below aren't recommended, they can also be used to deploy a manifest repeatedly.
If you have your host running in a separate shell/terminal window and want to avoid having to constantly wash app delete in-between changes to your project and/or manifest, you can run wash app deploy with the --replace option:
wash app deploy --replace path/to/your/wadm.yamlRunning wash app deploy with the --replace flag makes wash attempt to delete the application before attempting to deploy it.
Combine this with a tool like cargo watch (in the Rust ecosystem) and you can continuously re-deploy your manifest any time your Rust project changes:
cargo watch -- wash app deploy --replace path/to/your/wadm.yaml