A simple WebAssembly example

    If you have not done so already, follow these simple instructions to .

    1. cargo build --target wasm32-wasi --release

    The wasm bytecode application is in the target/wasm32-wasi/release/wasi_example_main.wasm file. You can now publish and use it as a container image.

    1. FROM scratch
    2. CMD ["/wasi_example_main.wasm"]

    Please note that adding self-defined annotation is still a new feature in buildah.

    The crun container runtime can start the above WebAssembly-based container image. But it requires the module.wasm.image/variant=compat annotation on the container image to indicate that it is a WebAssembly application without a guest OS. You can find the details in Official crun repo.

    To add module.wasm.image/variant=compat annotation in the container image, you will need the latest . Currently, Docker does not support this feature. Please follow the install instructions of buildah to build the latest buildah binary.

    Then, follow these steps to build and install buildah on Ubuntu.

    1. export GOPATH=`pwd`
    2. git clone https://github.com/containers/buildah ./src/github.com/containers/buildah
    3. cd ./src/github.com/containers/buildah
    4. PATH=/usr/lib/go-1.16/bin:$PATH make
    5. cp bin/buildah /usr/bin/buildah

    Create and publish a container image with buildah

    In the target/wasm32-wasi/release/ folder, do the following.

    That’s it! Now you can try to run it in or Kubernetes!