Skip to content

Commit f99ef83

Browse files
authored
unikernel config (#3)
1 parent e5717bd commit f99ef83

20 files changed

Lines changed: 601 additions & 5 deletions

File tree

README.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Overview
44

5-
Kernel provides containerized, ready-to-use Chrome browser environments for agentic workflows that need to access the Internet. `containers/docker/Dockerfile` is the core technology that powers our [hosted services](https://docs.onkernel.com/introduction).
5+
Kernel provides containerized, ready-to-use Chrome browser environments for agentic workflows that need to access the Internet. `containers/docker/Dockerfile` and `unikernels/unikraft-cu` are the core infra that powers our [hosted services](https://docs.onkernel.com/introduction).
66

77
### Key Features
88

@@ -33,6 +33,7 @@ docker run -p 8501:8501 -p 8080:8080 -p 6080:6080 -p 9222:9222 kernel-chromium
3333
```
3434

3535
This exposes three ports:
36+
3637
- `8080`: Anthropic's Computer Use web application, which includes a chat interface and remote GUI
3738
- `6080`: NoVNC interface for visual monitoring via browser-based VNC client
3839
- `9222`: Chrome DevTools Protocol for browser automation via Playwright and Puppeteer
@@ -45,25 +46,29 @@ This exposes three ports:
4546
You can connect to the browser using any CDP client.
4647

4748
First, fetch the browser's CDP websocket endpoint:
49+
4850
```typescript
4951
const response = await fetch("http://localhost:9222/json/version");
5052
if (response.status !== 200) {
51-
throw new Error(
53+
throw new Error(
5254
`Failed to retrieve browser instance: ${
53-
response.statusText
55+
response.statusText
5456
} ${await response.text()}`
55-
);
57+
);
5658
}
5759
const { webSocketDebuggerUrl } = await response.json();
5860
```
5961

6062
Then, connect a remote Playwright or Puppeteer client to it:
63+
6164
```typescript
6265
const browser = await puppeteer.connect({
63-
browserWSEndpoint:webSocketDebuggerUrl,
66+
browserWSEndpoint: webSocketDebuggerUrl,
6467
});
6568
```
69+
6670
or:
71+
6772
```typescript
6873
browser = await chromium.connectOverCDP(cdp_ws_url);
6974
```

unikernels/unikraft-cu/Dockerfile

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
FROM docker.io/ubuntu:22.04
2+
3+
ENV DEBIAN_FRONTEND=noninteractive
4+
ENV DEBIAN_PRIORITY=high
5+
6+
RUN apt-get update && \
7+
apt-get -y upgrade && \
8+
apt-get -y install \
9+
# UI Requirements
10+
xvfb \
11+
xterm \
12+
xdotool \
13+
scrot \
14+
imagemagick \
15+
sudo \
16+
mutter \
17+
x11vnc \
18+
# Python/pyenv reqs
19+
build-essential \
20+
libssl-dev \
21+
zlib1g-dev \
22+
libbz2-dev \
23+
libreadline-dev \
24+
libsqlite3-dev \
25+
curl \
26+
git \
27+
libncursesw5-dev \
28+
xz-utils \
29+
tk-dev \
30+
libxml2-dev \
31+
libxmlsec1-dev \
32+
libffi-dev \
33+
liblzma-dev \
34+
# Network tools
35+
net-tools \
36+
netcat \
37+
# PPA req
38+
software-properties-common && \
39+
# Userland apps
40+
sudo add-apt-repository ppa:mozillateam/ppa && \
41+
sudo apt-get install -y --no-install-recommends \
42+
chromium-browser \
43+
libreoffice \
44+
x11-apps \
45+
xpdf \
46+
gedit \
47+
xpaint \
48+
tint2 \
49+
galculator \
50+
pcmanfm \
51+
wget \
52+
xdg-utils \
53+
libvulkan1 \
54+
fonts-liberation \
55+
unzip && \
56+
apt-get clean
57+
58+
# install chromium & ncat for proxying the remote debugging port
59+
RUN add-apt-repository -y ppa:xtradeb/apps
60+
RUN apt update -y && apt install -y chromium ncat
61+
62+
# Install noVNC
63+
RUN git clone --branch v1.5.0 https://github.com/novnc/noVNC.git /opt/noVNC && \
64+
git clone --branch v0.12.0 https://github.com/novnc/websockify /opt/noVNC/utils/websockify && \
65+
ln -s /opt/noVNC/vnc.html /opt/noVNC/index.html
66+
67+
# setup desktop env & app
68+
ENV DISPLAY_NUM=1
69+
ENV HEIGHT=768
70+
ENV WIDTH=1024
71+
72+
COPY image-chromium/ /
73+
COPY ./wrapper.sh /wrapper.sh
74+
75+
ENTRYPOINT [ "/wrapper.sh" ]
76+

unikernels/unikraft-cu/Kraftfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
spec: v0.6
2+
3+
runtime: base-compat:latest
4+
5+
labels:
6+
cloud.unikraft.v1.instances/scale_to_zero.policy: "on"
7+
cloud.unikraft.v1.instances/scale_to_zero.stateful: "true"
8+
cloud.unikraft.v1.instances/scale_to_zero.cooldown_time_ms: 4000
9+
10+
rootfs: ./Dockerfile
11+
12+
cmd: ["/wrapper.sh"]

unikernels/unikraft-cu/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Originally taken and modified from: https://github.com/anthropics/anthropic-quickstarts/tree/main/computer-use-demo
2+
3+
To build / deploy:
4+
5+
1. export UKC_METRO=was1 and UKC_TOKEN=`<secret>`.
6+
2. run `./deploy.sh`

unikernels/unikraft-cu/deploy.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
name="kernel-cu"
4+
5+
kraft cloud deploy \
6+
-M 8192 \
7+
-p 443:6080/http+tls \
8+
-p 9222:9222/tls \
9+
-e DISPLAY_NUM=1 \
10+
-e HEIGHT=768 \
11+
-e WIDTH=1024 \
12+
-e HOME=/ \
13+
-n "$name" \
14+
.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[Desktop Entry]
2+
Name=Gedit
3+
Comment=Open gedit
4+
Exec=gedit
5+
Icon=text-editor-symbolic
6+
Terminal=false
7+
Type=Application
8+
Categories=TextEditor;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[Desktop Entry]
2+
Name=Terminal
3+
Comment=Open Terminal
4+
Exec=xterm
5+
Icon=utilities-terminal
6+
Terminal=false
7+
Type=Application
8+
Categories=System;TerminalEmulator;
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
#-------------------------------------
2+
# Panel
3+
panel_items = TL
4+
panel_size = 100% 60
5+
panel_margin = 0 0
6+
panel_padding = 2 0 2
7+
panel_background_id = 1
8+
wm_menu = 0
9+
panel_dock = 0
10+
panel_position = bottom center horizontal
11+
panel_layer = top
12+
panel_monitor = all
13+
panel_shrink = 0
14+
autohide = 0
15+
autohide_show_timeout = 0
16+
autohide_hide_timeout = 0.5
17+
autohide_height = 2
18+
strut_policy = follow_size
19+
panel_window_name = tint2
20+
disable_transparency = 1
21+
mouse_effects = 1
22+
font_shadow = 0
23+
mouse_hover_icon_asb = 100 0 10
24+
mouse_pressed_icon_asb = 100 0 0
25+
scale_relative_to_dpi = 0
26+
scale_relative_to_screen_height = 0
27+
28+
#-------------------------------------
29+
# Taskbar
30+
taskbar_mode = single_desktop
31+
taskbar_hide_if_empty = 0
32+
taskbar_padding = 0 0 2
33+
taskbar_background_id = 0
34+
taskbar_active_background_id = 0
35+
taskbar_name = 1
36+
taskbar_hide_inactive_tasks = 0
37+
taskbar_hide_different_monitor = 0
38+
taskbar_hide_different_desktop = 0
39+
taskbar_always_show_all_desktop_tasks = 0
40+
taskbar_name_padding = 4 2
41+
taskbar_name_background_id = 0
42+
taskbar_name_active_background_id = 0
43+
taskbar_name_font_color = #e3e3e3 100
44+
taskbar_name_active_font_color = #ffffff 100
45+
taskbar_distribute_size = 0
46+
taskbar_sort_order = none
47+
task_align = left
48+
49+
#-------------------------------------
50+
# Launcher
51+
launcher_padding = 4 8 4
52+
launcher_background_id = 0
53+
launcher_icon_background_id = 0
54+
launcher_icon_size = 48
55+
launcher_icon_asb = 100 0 0
56+
launcher_icon_theme_override = 0
57+
startup_notifications = 1
58+
launcher_tooltip = 1
59+
60+
#-------------------------------------
61+
# Launcher icon
62+
launcher_item_app = /usr/share/applications/libreoffice-calc.desktop
63+
launcher_item_app = /.config/tint2/applications/terminal.desktop
64+
launcher_item_app = /.config/tint2/applications/chromium-custom.desktop
65+
launcher_item_app = /usr/share/applications/xpaint.desktop
66+
launcher_item_app = /usr/share/applications/xpdf.desktop
67+
launcher_item_app = /.config/tint2/applications/gedit.desktop
68+
launcher_item_app = /usr/share/applications/galculator.desktop
69+
70+
#-------------------------------------
71+
# Background definitions
72+
# ID 1
73+
rounded = 0
74+
border_width = 0
75+
background_color = #000000 60
76+
border_color = #000000 30
77+
78+
# ID 2
79+
rounded = 4
80+
border_width = 1
81+
background_color = #777777 20
82+
border_color = #777777 30
83+
84+
# ID 3
85+
rounded = 4
86+
border_width = 1
87+
background_color = #777777 20
88+
border_color = #ffffff 40
89+
90+
# ID 4
91+
rounded = 4
92+
border_width = 1
93+
background_color = #aa4400 100
94+
border_color = #aa7733 100
95+
96+
# ID 5
97+
rounded = 4
98+
border_width = 1
99+
background_color = #aaaa00 100
100+
border_color = #aaaa00 100
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[server]
2+
fileWatcherType = "auto"
3+
runOnSave = true
4+
5+
[browser]
6+
gatherUsageStats = false
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
set -e
3+
4+
./start_all.sh
5+
./novnc_startup.sh
6+
7+
python http_server.py > /tmp/server_logs.txt 2>&1 &
8+
9+
STREAMLIT_SERVER_PORT=8501 python -m streamlit run computer_use_demo/streamlit.py > /tmp/streamlit_stdout.log &
10+
11+
echo "✨ Computer Use Demo is ready!"
12+
echo "➡️ Open http://localhost:8080 in your browser to begin"
13+
14+
# Keep the container running
15+
tail -f /dev/null

0 commit comments

Comments
 (0)