Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(library): Introduce WAMR #7

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 77 additions & 0 deletions .github/workflows/library-wamrbc762f.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: library/wamrbc76sf

on:
schedule:
- cron: '0 0 * * *' # Everyday at 12AM

push:
branches: [main]
paths:
- 'library/wamr/bc762f/**'
- '.github/workflows/library-wamrbc762f.yaml'

pull_request:
types: [opened, synchronize, reopened]
branches: [main]
paths:
- 'library/wamr/bc762f/**'
- '.github/workflows/library-wamrbc762f.yaml'

jobs:
build:
strategy:
fail-fast: false
matrix:
include:
- plat: qemu
arch: x86_64
- plat: qemu
arch: arm64
- plat: fc
arch: x86_64
- plat: fc
arch: arm64

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Build WAMR-bc762f
uses: unikraft/kraftkit@staging
with:
loglevel: debug
workdir: library/wamr/bc762f
runtimedir: /github/workspace/.kraftkit
plat: ${{ matrix.plat }}
arch: ${{ matrix.arch }}
push: false
output: oci://index.unikraft.io/unikraft.org/wamr:bc762f

- name: Archive OCI digests
uses: actions/upload-artifact@v3
with:
name: oci-digests-${{ matrix.arch }}-${{ matrix.plat }}
path: ${{ github.workspace }}/.kraftkit/oci/digests
if-no-files-found: error

push:
if: ${{ github.event_name == 'push' || github.event_name == 'schedule' }}
needs: [ build ]
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Login to OCI registry
uses: docker/login-action@v2
with:
registry: index.unikraft.io
username: ${{ secrets.REG_USERNAME }}
password: ${{ secrets.REG_TOKEN }}

- name: Retrieve, merge and push OCI digests
uses: ./.github/actions/merge-oci-digests
with:
name: index.unikraft.io/unikraft.org/wamr:bc762f
push: true
31 changes: 31 additions & 0 deletions library/wamr/bc762f/Kraftfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
spec: v0.6

name: wamr

rootfs: ./rootfs

cmd: ["/main.wasm"]

unikraft:
version: stable
kconfig:
CONFIG_LIBRAMFS: 'y'
CONFIG_LIBUK9P: 'y'
CONFIG_LIBUKBUS: 'y'
CONFIG_LIBUKCPIO: 'y'
CONFIG_LIBUKDEBUG_ANSI_COLOR: 'y'
CONFIG_LIBUKLIBPARAM: 'y'
CONFIG_LIBVFSCORE_AUTOMOUNT_ROOTFS: 'y'
CONFIG_LIBVFSCORE_FSTAB: 'y'
CONFIG_LIBVFSCORE_ROOTFS_INITRD: 'y'

targets:
- qemu/x86_64
- qemu/arm64
- fc/x86_64
- fc/arm64

libraries:
musl: stable
lwip: stable
wamr: stable
68 changes: 68 additions & 0 deletions library/wamr/bc762f/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# WAMR (Wasm Micro Runtime) Image

This directory contains the [WAMR (Wasm Micro Runtime)](https://github.com/bytecodealliance/wasm-micro-runtime) application running on Unikraft, in binary compatibility mode.
It implements a "Hello, World!" printing program in web assembly and runs it on Unikraft.

## Run and Use

Use `kraft` to run the image and start a Unikraft instance:

```bash
kraft run --rm --plat qemu --arch x86_64 unikraft.org/wamr:bc762f
```

If the `--plat` argument is left out, it defaults to `qemu`.
If the `--arch` argument is left out, it defaults to your system's CPU architecture.

Once executed, it will print a "Hello, World!" message.

## Inspect and Close

To list information about the Unikraft instance, use:

```bash
kraft ps
```

```text
TODO
```

The instance name is `TODO`.
To close the Unikraft instance, close the `kraft` process (e.g., via `Ctrl+c`) or run:

```bash
kraft rm TODO
```

## Build and Run Locally

The commands so far used the pre-built WAMR image available in the Unikraft registry.

In oder to to build a local WAMR image, clone this repository and `cd` into this directory.
Then use `kraft` to build an image locally:

```bash
kraft build --no-cache --no-update --plat qemu --arch x86_64
```

Similar to the `kraft run` command, if the `--plat` argument is left out, it defaults to `qemu`.
If the `--arch` argument is left out, it defaults to your system's CPU architecture.

In order to run the locally built image, use `.` (_dot_, the current directory) as the final argument to the `kraft run` command:

```bash
kraft run --rm --plat qemu --arch x86_64 .
```

Same as above, it will open port `8080` and wait for connections.

## `kraft` and `sudo`

Mixing invocations of `kraft` and `sudo` can lead to unexpected behavior.
Read more about how to start `kraft` without `sudo` at [https://unikraft.org/sudoless](https://unikraft.org/sudoless).

## Learn More

- [How to run unikernels locally](https://unikraft.org/docs/cli/running)
- [How to build `Dockerfile` root filesystems with BuildKit](https://unikraft.org/guides/building-dockerfile-images-with-buildkit)
Binary file added library/wamr/bc762f/rootfs/main.wasm
Binary file not shown.
Loading