Docker container that downloads a WASM compiled file and running using wasmedge runtime. Available as an open web service in Eyevinn Open Source Cloud.
Build container image:
% docker build -t wasm-runner:local .
Create a sample application (example in Rust)
fn main() {
println!("Hello, world!");
}Compile to wasm:
% rustup target add wasm32-wasip1
% rustc main.rs --target wasm32-wasip1
Upload main.wasm to a bucket for download and then run the container providing the URL to the WASM file:
% docker run --rm \
-p 8080:8080 \
-e WASM_URL=https://eyevinnlab-birme.minio-minio.auto.prod.osaas.io/code/main.wasm \
wasm-runner:local
Alternatively, provide a GitHub repository URL containing a .wasm file:
% docker run --rm \
-p 8080:8080 \
-e GITHUB_URL=https://github.com/<org>/<repo>/ \
wasm-runner:local
For private repositories, provide a GitHub personal access token:
% docker run --rm \
-p 8080:8080 \
-e GITHUB_URL=https://github.com/<org>/<repo>/ \
-e GITHUB_TOKEN=<token> \
wasm-runner:local
You can specify a branch using a URL fragment:
% docker run --rm \
-p 8080:8080 \
-e GITHUB_URL=https://github.com/<org>/<repo>#<branch> \
wasm-runner:local
The entrypoint will clone the repository, find the first .wasm file, and run it. The WASM module is expected to follow the WASI convention and export a _start entry point (the default for wasmedge).
The WASM application main.wasm can now be invoked through the HTTP server on port 8080. Provides these endpoints:
| Method | Path | Description |
|---|---|---|
| GET | / | Invoke the application and return what the application writes to STDOUT |
| POST | / | Invoke the application and the request body is provided to the application on STDIN. Return STDOUT output |
% curl http://localhost:8080/
Hello, world!
| Variable | Required | Description |
|---|---|---|
WASM_URL |
Yes* | URL to a .wasm file to download and run. Mutually exclusive with GITHUB_URL / GIT_URL. |
GITHUB_URL |
Yes* | URL to a GitHub repository containing a .wasm file. Mutually exclusive with WASM_URL. Alias for GIT_URL. |
GIT_URL |
Yes* | URL to a Git repository containing a .wasm file. Supports a branch suffix (#<branch>). Mutually exclusive with WASM_URL. |
GITHUB_TOKEN |
No | Personal access token for cloning private GitHub repositories. Alias for GIT_TOKEN. |
GIT_TOKEN |
No | Personal access token for cloning private Git repositories. |
CONFIG_SVC |
No | Hostname of the OSC parameter store service. When set alongside OSC_ACCESS_TOKEN, environment variables are loaded from the config service before the WASM module starts. |
OSC_ACCESS_TOKEN |
No | OSC service access token. Required for config service integration (CONFIG_SVC). |
CONFIG_API_KEY |
No | API key for encrypted parameter store. When set alongside OSC_ACCESS_TOKEN and CONFIG_SVC, secret parameters are decrypted before being injected as environment variables. |
* Exactly one of WASM_URL, GITHUB_URL, or GIT_URL must be provided.
See CONTRIBUTING
This project is licensed under the MIT License, see LICENSE.
Join our community on Slack where you can post any questions regarding any of our open source projects. Eyevinn's consulting business can also offer you:
- Further development of this component
- Customization and integration of this component into your platform
- Support and maintenance agreement
Contact sales@eyevinn.se if you are interested.
Eyevinn Technology is an independent consultant firm specialized in video and streaming. Independent in a way that we are not commercially tied to any platform or technology vendor. As our way to innovate and push the industry forward we develop proof-of-concepts and tools. The things we learn and the code we write we share with the industry in blogs and by open sourcing the code we have written.
Want to know more about Eyevinn and how it is to work here. Contact us at work@eyevinn.se!