Skip to content

Commit bcdbc28

Browse files
committed
Rewrite chromium-headful + chromium-headless wrapper as a Go binary
Replaces the bash wrapper.sh shipped in both browser images with a single Go binary (server/cmd/wrapper) that detects the headful vs headless profile from supervisor's conf.d at boot. The Go wrapper preserves behaviour parity with the bash scripts but removes serial dead time on the boot path: - Phase A starts xorg/xvfb, dbus, and chromedriver in a single supervisorctl invocation; readiness is then probed concurrently. - Envoy bootstrap (cert generation, NSS DB, template render) runs in a goroutine alongside Phase A. Phase B gates on it because chromium reads the system CA trust store at process start. - Phase B starts chromium, kernel-images-api, and (headful) mutter + optional neko in one call so their bring-up overlaps chromium boot. - Final readiness waits on the union of CDP, chromedriver, forward-proxy, and (when enabled) neko + envoy in parallel. Per-service tweaks: - supervisor confs: startsecs=2 → 0 so supervisorctl start returns as soon as the program is launched (Go probes readiness directly). - init-envoy.sh: drop the trailing 50-iteration port poll and curl-through-proxy test; the Go wrapper's waitAllReady covers it. - Kraftfile cmd updated from /wrapper.sh to /wrapper. Cosmetic + non-critical work (pulseaudio, --no-sandbox infobar dismissal) runs off the hot path.
1 parent ba17894 commit bcdbc28

20 files changed

Lines changed: 626 additions & 685 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ Deployed successfully!
8383
├────── service: <service_name>
8484
├─ private fqdn: <id>
8585
├─── private ip: <ip>
86-
└───────── args: /wrapper.sh
86+
└───────── args: /wrapper
8787
```
8888

8989
### Unikernel Notes

images/chromium-headful/Dockerfile

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ RUN --mount=type=cache,target=/root/.cache/go-build,id=$CACHEIDPREFIX-go-build \
2727
GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH:-amd64} \
2828
go build -ldflags="-s -w" -o /out/chromium-launcher ./cmd/chromium-launcher
2929

30+
# Build container entrypoint wrapper (replaces wrapper.sh)
31+
RUN --mount=type=cache,target=/root/.cache/go-build,id=$CACHEIDPREFIX-go-build \
32+
--mount=type=cache,target=/go/pkg/mod,id=$CACHEIDPREFIX-go-pkg-mod \
33+
GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH:-amd64} \
34+
go build -ldflags="-s -w" -o /out/wrapper ./cmd/wrapper
35+
3036
# webrtc client
3137
FROM node:22-bullseye-slim AS client
3238
WORKDIR /src
@@ -348,7 +354,6 @@ COPY --from=xorg-deps /usr/local/lib/xorg/modules/input/neko_drv.so /usr/lib/xor
348354
COPY images/chromium-headful/image-chromium/ /
349355
COPY images/chromium-headful/start-pulseaudio.sh /images/chromium-headful/start-pulseaudio.sh
350356
RUN chmod +x /images/chromium-headful/start-pulseaudio.sh
351-
COPY images/chromium-headful/wrapper.sh /wrapper.sh
352357
COPY images/chromium-headful/supervisord.conf /etc/supervisor/supervisord.conf
353358
COPY images/chromium-headful/supervisor/services/ /etc/supervisor/conf.d/services/
354359
COPY shared/envoy/supervisor-envoy.conf /etc/supervisor/conf.d/services/envoy.conf
@@ -365,6 +370,7 @@ RUN chmod +x /usr/local/bin/init-envoy.sh
365370
# copy the kernel-images API binary built in the builder stage
366371
COPY --from=server-builder /out/kernel-images-api /usr/local/bin/kernel-images-api
367372
COPY --from=server-builder /out/chromium-launcher /usr/local/bin/chromium-launcher
373+
COPY --from=server-builder /out/wrapper /wrapper
368374

369375
# Copy and compile the Playwright daemon
370376
COPY server/runtime/playwright-daemon.ts /tmp/playwright-daemon.ts
@@ -381,4 +387,4 @@ RUN esbuild /tmp/playwright-daemon.ts \
381387

382388
RUN useradd -m -s /bin/bash kernel
383389

384-
ENTRYPOINT [ "/wrapper.sh" ]
390+
ENTRYPOINT [ "/wrapper" ]

images/chromium-headful/Kraftfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ labels:
99

1010
rootfs: ./initrd
1111

12-
cmd: ["/wrapper.sh"]
12+
cmd: ["/wrapper"]

images/chromium-headful/supervisor/services/chromedriver.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
command=/usr/local/bin/chromedriver --port=9225 --allowed-ips=127.0.0.1 --log-level=INFO
33
autostart=false
44
autorestart=true
5-
startsecs=2
5+
startsecs=0
66
stdout_logfile=/var/log/supervisord/chromedriver
77
redirect_stderr=true

images/chromium-headful/supervisor/services/dbus.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
command=/bin/bash -lc 'mkdir -p /run/dbus && dbus-uuidgen --ensure && dbus-daemon --system --address=unix:path=/run/dbus/system_bus_socket --nopidfile --nosyslog --nofork'
33
autostart=false
44
autorestart=true
5-
startsecs=2
5+
startsecs=0
66
stdout_logfile=/var/log/supervisord/dbus
77
redirect_stderr=true

images/chromium-headful/supervisor/services/kernel-images-api.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
command=/bin/bash -lc 'mkdir -p "${KERNEL_IMAGES_API_OUTPUT_DIR:-/recordings}" && PORT="${KERNEL_IMAGES_API_PORT:-10001}" FRAME_RATE="${KERNEL_IMAGES_API_FRAME_RATE:-10}" DISPLAY_NUM="${KERNEL_IMAGES_API_DISPLAY_NUM:-${DISPLAY_NUM:-1}}" MAX_SIZE_MB="${KERNEL_IMAGES_API_MAX_SIZE_MB:-500}" OUTPUT_DIR="${KERNEL_IMAGES_API_OUTPUT_DIR:-/recordings}" LOG_CDP_MESSAGES="${LOG_CDP_MESSAGES:-false}" exec /usr/local/bin/kernel-images-api'
33
autostart=false
44
autorestart=true
5-
startsecs=2
5+
startsecs=0
66
stdout_logfile=/var/log/supervisord/kernel-images-api
77
redirect_stderr=true

images/chromium-headful/supervisor/services/mutter.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
command=/bin/bash -lc 'XDG_SESSION_TYPE=x11 mutter --replace --sm-disable'
33
autostart=false
44
autorestart=true
5-
startsecs=2
5+
startsecs=0
66
stdout_logfile=/var/log/supervisord/mutter
77
redirect_stderr=true

images/chromium-headful/supervisor/services/neko.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
command=/usr/bin/neko serve --server.static /var/www --server.bind 0.0.0.0:8080
33
autostart=false
44
autorestart=true
5-
startsecs=2
5+
startsecs=0
66
stdout_logfile=/var/log/supervisord/neko
77
redirect_stderr=true

images/chromium-headful/supervisor/services/xorg.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
command=/usr/bin/Xorg :1 -config /etc/neko/xorg.conf -noreset -nolisten tcp
33
autostart=false
44
autorestart=true
5-
startsecs=2
5+
startsecs=0
66
stdout_logfile=/var/log/supervisord/xorg
77
redirect_stderr=true

0 commit comments

Comments
 (0)