Skip to content

Commit bdaa54f

Browse files
rgarciaDebianCopilot
authored
allow customizing chromium flags (#11)
* split up build and run * allow customizing chromium flags * Update shared/start-buildkit.sh Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Debian <admin@ip-10-0-2-186.ec2.internal> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 61819a6 commit bdaa54f

File tree

8 files changed

+72
-33
lines changed

8 files changed

+72
-33
lines changed

containers/docker/Dockerfile

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,7 @@ CHROME_PORT=9222 # External port mapped in Docker
3030
echo "Starting Chromium on internal port $INTERNAL_PORT"
3131
DISPLAY=:1 chromium \
3232
--remote-debugging-port=$INTERNAL_PORT \
33-
--no-sandbox \
34-
--disable-dev-shm-usage \
35-
--disable-gpu \
36-
--start-maximized \
37-
--disable-software-rasterizer \
38-
--remote-allow-origins=* \
39-
--no-zygote >&2 &
33+
${CHROMIUM_FLAGS:-} >&2 &
4034

4135
echo "Setting up ncat proxy on port $CHROME_PORT"
4236
ncat \

containers/docker/README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ docker build -t onkernel/kernel-chromium:latest -f containers/docker/Dockerfile
1313
## 2. Run the Container
1414

1515
```bash
16-
docker run -p 8501:8501 -p 8080:8080 -p 6080:6080 -p 9222:9222 kernel-chromium
16+
docker run -e CHROMIUM_FLAGS="--no-sandbox --disable-dev-shm-usage --disable-gpu --start-maximized --disable-software-rasterizer --remote-allow-origins=* --no-zygote" -p 8501:8501 -p 8080:8080 -p 6080:6080 -p 9222:9222 kernel-chromium
1717
```
1818

1919
This exposes three ports:
@@ -24,10 +24,12 @@ This exposes three ports:
2424
- `8501`: Streamlit interfaced used by Computer Use
2525

2626
## Live View Configuration
27-
You can set the browser width and height with the environment variables `WIDTH` and `HEIGHT` in the `docker run` command:
27+
You can set the browser width and height with the environment variables `WIDTH` and `HEIGHT`, and control Chromium startup flags with `CHROMIUM_FLAGS` in the `docker run` command:
2828

2929
```bash
30-
docker run -e WIDTH=1920 -e HEIGHT=1080 -p 8501:8501 -p 8080:8080 -p 6080:6080 -p 9222:9222 kernel-chromium
30+
docker run -e WIDTH=1920 -e HEIGHT=1080 \
31+
-e CHROMIUM_FLAGS="--start-maximized --disable-gpu" \
32+
-p 8501:8501 -p 8080:8080 -p 6080:6080 -p 9222:9222 kernel-chromium
3133
```
3234

3335
## 👾 Connect via Chrome DevTools Protocol

shared/start-buildkit.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env bash
2+
3+
# This script MUST be sourced (i.e. use `source start-buildkit.sh`).
4+
5+
# Variable used by KraftKit, hence the requirement for sourcing the script
6+
export KRAFTKIT_BUILDKIT_HOST=docker-container://buildkit
7+
8+
# Install container if not already installed.
9+
docker container inspect buildkit > /dev/null 2>&1
10+
if test $? -eq 0; then
11+
echo "Container 'buildkit' is already installed. Nothing to do."
12+
else
13+
echo "Installing 'buildkit' container ... "
14+
docker run -d --name buildkit --privileged moby/buildkit:latest
15+
return $?
16+
fi
17+
18+
test "$(docker container inspect -f '{{.State.Running}}' buildkit 2> /dev/null)" = "true"
19+
if test $? -eq 0; then
20+
echo "Container 'buidlkitd' is already running. Nothing to do."
21+
else
22+
echo "Starting 'buildkit' container ... "
23+
docker start buildkit
24+
return $?
25+
fi

unikernels/unikraft-cu/README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@ This deploys headful Chromium on a unikernel. It also exposes a remote GUI throu
1111
## 2. Add Unikraft Secret to Your CLI
1212
`export UKC_METRO=<region> and UKC_TOKEN=<secret>`
1313

14-
## 3. Deploy the Implementation
15-
`./deploy.sh`
14+
## 3. Build the image
15+
`./build.sh`
16+
17+
## 4. Run it
18+
`./run.sh`
1619

1720
When the deployment finishes successfully, the Kraft CLI will print out something like this:
1821
```

unikernels/unikraft-cu/build.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env bash
2+
3+
# namespace here (onkernel) should match UKC_TOKEN's username
4+
image="onkernel/kernel-cu-test:latest"
5+
6+
# fail if UKC_TOKEN and UKC_METRO are not set
7+
if [ -z "$UKC_TOKEN" ] || [ -z "$UKC_METRO" ]; then
8+
echo "UKC_TOKEN and UKC_METRO must be set"
9+
exit 1
10+
fi
11+
source ../../shared/start-buildkit.sh
12+
13+
kraft pkg \
14+
--name index.unikraft.io/$image \
15+
--plat kraftcloud --arch x86_64 \
16+
--strategy overwrite \
17+
--push \
18+
.

unikernels/unikraft-cu/deploy.sh

Lines changed: 0 additions & 14 deletions
This file was deleted.

unikernels/unikraft-cu/run.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env bash
2+
3+
image="onkernel/kernel-cu-test:latest"
4+
name="kernel-cu-test"
5+
6+
kraft cloud inst create \
7+
--start
8+
-M 8192 \
9+
-p 443:6080/http+tls \
10+
-p 9222:9222/tls \
11+
-e DISPLAY_NUM=1 \
12+
-e HEIGHT=768 \
13+
-e WIDTH=1024 \
14+
-e HOME=/ \
15+
-e CHROMIUM_FLAGS="--no-sandbox --disable-dev-shm-usage --disable-gpu --start-maximized --disable-software-rasterizer --remote-allow-origins=* --no-zygote" \
16+
-n "$name" \
17+
$image

unikernels/unikraft-cu/wrapper.sh

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,7 @@ CHROME_PORT=9222 # External port mapped to host
2424
echo "Starting Chromium on internal port $INTERNAL_PORT"
2525
DISPLAY=:1 chromium \
2626
--remote-debugging-port=$INTERNAL_PORT \
27-
--no-sandbox \
28-
--disable-dev-shm-usage \
29-
--disable-gpu \
30-
--start-maximized \
31-
--disable-software-rasterizer \
32-
--remote-allow-origins=* \
33-
--no-zygote >&2 &
27+
${CHROMIUM_FLAGS:-} >&2 &
3428
echo "Setting up ncat proxy on port $CHROME_PORT"
3529
ncat \
3630
--sh-exec "ncat 0.0.0.0 $INTERNAL_PORT" \

0 commit comments

Comments
 (0)