Skip to content

Commit 6f1030c

Browse files
committed
feat(library): Introduce WAMR
Introduce WAMR (Wasm Micro Runtime) native application for Unikraft. The version used is an older commit (pre-stable release): `bc762f`. Add required files: `Kraftfile`, `Makefile.uk` and `README.md`. The root filesystem (in `rootfs/`) provides the pre-built `main.wasm` file, passed to as the `cmd` in `Kraftfile`. Signed-off-by: Razvan Deaconescu <razvand@unikraft.io>
1 parent e5d824f commit 6f1030c

File tree

4 files changed

+176
-0
lines changed

4 files changed

+176
-0
lines changed
+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: library/wamrbc76sf
2+
3+
on:
4+
schedule:
5+
- cron: '0 0 * * *' # Everyday at 12AM
6+
7+
push:
8+
branches: [main]
9+
paths:
10+
- 'library/wamr/bc762f/**'
11+
- '.github/workflows/library-wamrbc762f.yaml'
12+
13+
pull_request:
14+
types: [opened, synchronize, reopened]
15+
branches: [main]
16+
paths:
17+
- 'library/wamr/bc762f/**'
18+
- '.github/workflows/library-wamrbc762f.yaml'
19+
20+
jobs:
21+
build:
22+
strategy:
23+
fail-fast: false
24+
matrix:
25+
include:
26+
- plat: qemu
27+
arch: x86_64
28+
- plat: qemu
29+
arch: arm64
30+
- plat: fc
31+
arch: x86_64
32+
- plat: fc
33+
arch: arm64
34+
35+
runs-on: ubuntu-latest
36+
37+
steps:
38+
- uses: actions/checkout@v3
39+
40+
- name: Build WAMR-bc762f
41+
uses: unikraft/kraftkit@staging
42+
with:
43+
loglevel: debug
44+
workdir: library/wamr/bc762f
45+
runtimedir: /github/workspace/.kraftkit
46+
plat: ${{ matrix.plat }}
47+
arch: ${{ matrix.arch }}
48+
push: false
49+
output: oci://index.unikraft.io/unikraft.org/wamr:bc762f
50+
51+
- name: Archive OCI digests
52+
uses: actions/upload-artifact@v3
53+
with:
54+
name: oci-digests-${{ matrix.arch }}-${{ matrix.plat }}
55+
path: ${{ github.workspace }}/.kraftkit/oci/digests
56+
if-no-files-found: error
57+
58+
push:
59+
if: ${{ github.event_name == 'push' || github.event_name == 'schedule' }}
60+
needs: [ build ]
61+
runs-on: ubuntu-latest
62+
63+
steps:
64+
- uses: actions/checkout@v3
65+
66+
- name: Login to OCI registry
67+
uses: docker/login-action@v2
68+
with:
69+
registry: index.unikraft.io
70+
username: ${{ secrets.REG_USERNAME }}
71+
password: ${{ secrets.REG_TOKEN }}
72+
73+
- name: Retrieve, merge and push OCI digests
74+
uses: ./.github/actions/merge-oci-digests
75+
with:
76+
name: index.unikraft.io/unikraft.org/wamr:bc762f
77+
push: true

library/wamr/bc762f/Kraftfile

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
spec: v0.6
2+
3+
name: wamr
4+
5+
rootfs: ./rootfs
6+
7+
cmd: ["/main.wasm"]
8+
9+
unikraft:
10+
version: stable
11+
kconfig:
12+
CONFIG_LIBRAMFS: 'y'
13+
CONFIG_LIBUK9P: 'y'
14+
CONFIG_LIBUKBUS: 'y'
15+
CONFIG_LIBUKCPIO: 'y'
16+
CONFIG_LIBUKDEBUG_ANSI_COLOR: 'y'
17+
CONFIG_LIBUKLIBPARAM: 'y'
18+
CONFIG_LIBVFSCORE_AUTOMOUNT_ROOTFS: 'y'
19+
CONFIG_LIBVFSCORE_FSTAB: 'y'
20+
CONFIG_LIBVFSCORE_ROOTFS_INITRD: 'y'
21+
22+
targets:
23+
- qemu/x86_64
24+
- qemu/arm64
25+
- fc/x86_64
26+
- fc/arm64
27+
28+
libraries:
29+
musl: stable
30+
lwip: stable
31+
wamr: stable

library/wamr/bc762f/README.md

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# WAMR (Wasm Micro Runtime) Image
2+
3+
This directory contains the [WAMR (Wasm Micro Runtime)](https://github.com/bytecodealliance/wasm-micro-runtime) application running on Unikraft, in binary compatibility mode.
4+
It implements a "Hello, World!" printing program in web assembly and runs it on Unikraft.
5+
6+
## Run and Use
7+
8+
Use `kraft` to run the image and start a Unikraft instance:
9+
10+
```bash
11+
kraft run --rm --plat qemu --arch x86_64 unikraft.org/wamr:bc762f
12+
```
13+
14+
If the `--plat` argument is left out, it defaults to `qemu`.
15+
If the `--arch` argument is left out, it defaults to your system's CPU architecture.
16+
17+
Once executed, it will print a "Hello, World!" message.
18+
19+
## Inspect and Close
20+
21+
To list information about the Unikraft instance, use:
22+
23+
```bash
24+
kraft ps
25+
```
26+
27+
```text
28+
TODO
29+
```
30+
31+
The instance name is `TODO`.
32+
To close the Unikraft instance, close the `kraft` process (e.g., via `Ctrl+c`) or run:
33+
34+
```bash
35+
kraft rm TODO
36+
```
37+
38+
## Build and Run Locally
39+
40+
The commands so far used the pre-built WAMR image available in the Unikraft registry.
41+
42+
In oder to to build a local WAMR image, clone this repository and `cd` into this directory.
43+
Then use `kraft` to build an image locally:
44+
45+
```bash
46+
kraft build --no-cache --no-update --plat qemu --arch x86_64
47+
```
48+
49+
Similar to the `kraft run` command, if the `--plat` argument is left out, it defaults to `qemu`.
50+
If the `--arch` argument is left out, it defaults to your system's CPU architecture.
51+
52+
In order to run the locally built image, use `.` (_dot_, the current directory) as the final argument to the `kraft run` command:
53+
54+
```bash
55+
kraft run --rm --plat qemu --arch x86_64 .
56+
```
57+
58+
Same as above, it will open port `8080` and wait for connections.
59+
60+
## `kraft` and `sudo`
61+
62+
Mixing invocations of `kraft` and `sudo` can lead to unexpected behavior.
63+
Read more about how to start `kraft` without `sudo` at [https://unikraft.org/sudoless](https://unikraft.org/sudoless).
64+
65+
## Learn More
66+
67+
- [How to run unikernels locally](https://unikraft.org/docs/cli/running)
68+
- [How to build `Dockerfile` root filesystems with BuildKit](https://unikraft.org/guides/building-dockerfile-images-with-buildkit)

library/wamr/bc762f/rootfs/main.wasm

1.36 KB
Binary file not shown.

0 commit comments

Comments
 (0)