Skip to content

Commit f9636f8

Browse files
xonkernelrgarcia
andauthored
feat: add WebRTC live streaming option as alternative to noVNC (#12)
* feat: add WebRTC live streaming option as alternative to noVNC This adds support for WebRTC-based live streaming of browser content, providing a lower-latency alternative to the existing noVNC solution. * docs: add explanation for /dev/shm mounting logic * chore: add comment for neko.yaml and remove some unused config variables * chore: update Node image to latest LTS (v22) * chore: remove sleeps in bootstrap scripts * chore: move xclip installation alongside other neko-related dependencies for consistency * chore(config): enable implicit_hosting to auto-unlock screen control * chore(config): move some env var config to YAML file * feat(ui): hide video overlay icons * docker run instructions and consistently exposing vnc or neko on main 443 port --------- Co-authored-by: Rafael Garcia <[email protected]>
1 parent eddba20 commit f9636f8

File tree

250 files changed

+92266
-20
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

250 files changed

+92266
-20
lines changed

unikernels/unikraft-cu/Dockerfile

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,38 @@
1+
# webrtc client
2+
FROM node:22-bullseye-slim AS client
3+
WORKDIR /src
4+
COPY client/package*.json ./
5+
RUN npm install
6+
COPY client/ .
7+
RUN npm run build
8+
9+
# xorg dependencies
10+
FROM docker.io/ubuntu:22.04 AS xorg-deps
11+
WORKDIR /xorg
12+
ENV DEBIAN_FRONTEND=noninteractive
13+
RUN set -eux; \
14+
apt-get update; \
15+
apt-get install -y \
16+
git gcc pkgconf autoconf automake libtool make xorg-dev xutils-dev \
17+
&& rm -rf /var/lib/apt/lists/*;
18+
COPY xorg-deps/ /xorg/
19+
# build xf86-video-dummy v0.3.8 with RandR support
20+
RUN set -eux; \
21+
cd xf86-video-dummy/v0.3.8; \
22+
patch -p1 < ../01_v0.3.8_xdummy-randr.patch; \
23+
autoreconf -v --install; \
24+
./configure; \
25+
make -j$(nproc); \
26+
make install;
27+
# build custom input driver
28+
RUN set -eux; \
29+
cd xf86-input-neko; \
30+
./autogen.sh --prefix=/usr; \
31+
./configure; \
32+
make -j$(nproc); \
33+
make install;
34+
35+
FROM ghcr.io/m1k1o/neko/chromium:3.0.6 AS neko
136
FROM docker.io/ubuntu:22.04
237

338
ENV DEBIAN_FRONTEND=noninteractive
@@ -55,6 +90,41 @@ RUN apt-get update && \
5590
unzip && \
5691
apt-get clean
5792

93+
# runtime
94+
ENV USERNAME=root
95+
RUN set -eux; \
96+
apt-get update; \
97+
apt-get install -y --no-install-recommends \
98+
wget ca-certificates python2 supervisor xclip \
99+
pulseaudio dbus-x11 xserver-xorg-video-dummy \
100+
libcairo2 libxcb1 libxrandr2 libxv1 libopus0 libvpx7 \
101+
gstreamer1.0-plugins-base gstreamer1.0-plugins-good \
102+
gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly \
103+
gstreamer1.0-pulseaudio gstreamer1.0-omx; \
104+
#
105+
# install libxcvt0 (not available in debian:bullseye)
106+
ARCH=$(dpkg --print-architecture); \
107+
wget http://ftp.de.debian.org/debian/pool/main/libx/libxcvt/libxcvt0_0.1.2-1_${ARCH}.deb; \
108+
apt-get install --no-install-recommends ./libxcvt0_0.1.2-1_${ARCH}.deb; \
109+
rm ./libxcvt0_0.1.2-1_${ARCH}.deb; \
110+
#
111+
# workaround for an X11 problem: http://blog.tigerteufel.de/?p=476
112+
mkdir /tmp/.X11-unix; \
113+
chmod 1777 /tmp/.X11-unix; \
114+
chown $USERNAME /tmp/.X11-unix/; \
115+
#
116+
# make directories for neko
117+
mkdir -p /etc/neko /var/www /var/log/neko \
118+
/tmp/runtime-$USERNAME \
119+
/home/$USERNAME/.config/pulse \
120+
/home/$USERNAME/.local/share/xorg; \
121+
chmod 1777 /var/log/neko; \
122+
chown $USERNAME /var/log/neko/ /tmp/runtime-$USERNAME; \
123+
chown -R $USERNAME:$USERNAME /home/$USERNAME; \
124+
# clean up
125+
apt-get clean -y; \
126+
rm -rf /var/lib/apt/lists/* /var/cache/apt/
127+
58128
# install chromium & ncat for proxying the remote debugging port
59129
RUN add-apt-repository -y ppa:xtradeb/apps
60130
RUN apt update -y && apt install -y chromium ncat
@@ -68,6 +138,14 @@ RUN git clone --branch v1.5.0 https://github.com/novnc/noVNC.git /opt/noVNC && \
68138
ENV DISPLAY_NUM=1
69139
ENV HEIGHT=768
70140
ENV WIDTH=1024
141+
ENV WITHDOCKER=true
142+
143+
COPY xorg.conf /etc/neko/xorg.conf
144+
COPY neko.yaml /etc/neko/neko.yaml
145+
COPY --from=neko /usr/bin/neko /usr/bin/neko
146+
COPY --from=client /src/dist/ /var/www
147+
COPY --from=xorg-deps /usr/local/lib/xorg/modules/drivers/dummy_drv.so /usr/lib/xorg/modules/drivers/dummy_drv.so
148+
COPY --from=xorg-deps /usr/local/lib/xorg/modules/input/neko_drv.so /usr/lib/xorg/modules/input/neko_drv.so
71149

72150
COPY image-chromium/ /
73151
COPY ./wrapper.sh /wrapper.sh

unikernels/unikraft-cu/README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,17 @@ Deployed successfully!
3434
└───────── args: /wrapper.sh
3535
```
3636

37+
### 3.1 Deploy the Implementation with WebRTC desktop streaming enabled
38+
```sh
39+
ENABLE_WEBRTC=true NEKO_ICESERVERS=xxx ./run.sh
40+
```
41+
42+
`NEKO_ICESERVERS`
43+
* Describes multiple STUN and TURN server that can be used by the ICEAgent to establish a connection with a peer.
44+
* e.g. `[{"urls": ["turn:turn.example.com:19302", "stun:stun.example.com:19302"], "username": "name", "credential": "password"}, {"urls": ["stun:stun.example2.com:19302"]}]`
45+
46+
WebRTC web client will run at port `8080`.
47+
3748
## 🧑‍💻 Connect via remote GUI (noVNC)
3849

3950
This implementation maps a noVNC remote GUI to the host port. You can access it by visiting the `domain` listed in Kraft's CLI output above. The remote GUI supports both read and write actions on the browser.
@@ -95,6 +106,30 @@ const browser = await chromium.connectOverCDP(finalWSUrl);
95106
- You can call `browser.close()` to disconnect to the browser, and the unikernel will go into standby after network activity ends. You can then reconnect to the instance using CDP. `browser.close()` ends the websocket connection but doesn't actually close the browser.
96107
- See this repo's [homepage](/README.md) for some benefits of putting Chromium on a unikernel.
97108

109+
## Docker
110+
111+
You can also run the Dockerfile directly as a docker container:
112+
113+
```sh
114+
docker build -t kernel-docker .
115+
docker run -d \
116+
-p 8080:8080 \
117+
-p 9222:9222 \
118+
--cap-add SYS_ADMIN \
119+
-p 56000-56100:56000-56100/udp \
120+
-e ENABLE_WEBRTC=true \
121+
-e CHROMIUM_FLAGS="--no-sandbox --disable-dev-shm-usage --disable-gpu --start-maximized --disable-software-rasterizer --remote-allow-origins=* --no-zygote" \
122+
-e NEKO_WEBRTC_EPR=56000-56100 \
123+
-e NEKO_WEBRTC_NAT1TO1=127.0.0.1 \
124+
kernel-docker
125+
```
126+
127+
## 📞 WebRTC Notes
128+
129+
- Deploying to Unikraft Cloud requires the usage of a [TURN](https://webrtc.org/getting-started/turn-server), as direct exposure of UDP ports is not currently supported.
130+
- WebRTC functionality is enabled through customized components of [neko](https://github.com/m1k1o/neko).
131+
- TODO: Audio streaming is currently non-functional and needs to be fixed.
132+
98133
## 🤝 License & Contributing
99134
See [here](/README.md) for license and contributing details.
100135

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"presets": ["@vue/cli-plugin-babel/preset"]
3+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
> 1%
2+
last 2 versions
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
indent_style = space
6+
indent_size = 2
7+
end_of_line = lf
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"root": true,
3+
"env": {
4+
"node": true
5+
},
6+
"extends": ["plugin:vue/essential", "@vue/prettier", "@vue/typescript"],
7+
"parserOptions": {
8+
"parser": "@typescript-eslint/parser"
9+
},
10+
"rules": {
11+
"vue/valid-v-for": "off",
12+
"no-case-declarations": "off",
13+
"no-dupe-class-members": "off",
14+
"no-console": "off",
15+
"no-empty": "off"
16+
}
17+
}
18+
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"semi": false,
3+
"trailingComma": "all",
4+
"singleQuote": true,
5+
"printWidth": 120,
6+
"tabWidth": 2,
7+
"vueIndentScriptAndStyle": true
8+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"editor.tabSize": 2,
3+
"editor.insertSpaces": true,
4+
"editor.detectIndentation": false,
5+
"files.encoding": "utf8",
6+
"files.eol": "\n",
7+
"typescript.tsdk": "./node_modules/typescript/lib",
8+
"todo-tree.filtering.excludeGlobs": ["**/node_modules/**"],
9+
"eslint.validate": [
10+
"vue",
11+
"javascript",
12+
"javascriptreact",
13+
"typescript",
14+
"typescriptreact",
15+
],
16+
"vetur.validation.template": true,
17+
"vetur.useWorkspaceDependencies": true,
18+
"remote.extensionKind": {
19+
"ms-azuretools.vscode-docker": "ui"
20+
},
21+
"editor.formatOnSave": false,
22+
"editor.codeActionsOnSave": {
23+
"source.fixAll.eslint": true
24+
},
25+
"remote.containers.defaultExtensions": [
26+
"octref.vetur",
27+
"esbenp.prettier-vscode",
28+
"dbaeumer.vscode-eslint",
29+
"ms-vscode-remote.vscode-remote-extensionpack",
30+
"ms-vscode-remote.remote-containers",
31+
"ms-azuretools.vscode-docker",
32+
"editorconfig.editorconfig",
33+
"gruntfuggly.todo-tree",
34+
"eamodio.gitlens",
35+
"swyphcosmo.spellchecker"
36+
],
37+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
ARG BASE_IMAGE=node:18-bullseye-slim
2+
FROM $BASE_IMAGE AS client
3+
4+
WORKDIR /src
5+
6+
#
7+
# install dependencies
8+
COPY package*.json ./
9+
RUN npm install
10+
11+
#
12+
# build client
13+
COPY . .
14+
RUN npm run build
15+
16+
#
17+
# artifacts from this stage
18+
# COPY --from=client /src/dist/ /var/www
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/sh
2+
cd "$(dirname "$0")"
3+
4+
# start component watch
5+
docker run --rm -it \
6+
--user "$(id -u):$(id -g)" \
7+
--volume "${PWD}/../:/app" \
8+
--entrypoint="npm" \
9+
--workdir="/app" \
10+
node:18-bullseye-slim run build

0 commit comments

Comments
 (0)