Commit 452efe9
Rewrite chromium wrapper.sh as a Go binary (#234)
## Summary
Replaces the bash `wrapper.sh` shipped in `chromium-headful` and
`chromium-headless` with a single Go binary (`server/cmd/wrapper`) that
detects the profile at boot from supervisor's `conf.d` (`xorg.conf` →
headful, `xvfb.conf` → headless).
The wrapper is split into two phases so identity-bound work doesn't
block boot:
- **Phase A** (identity-free) starts `xorg`/`xvfb`, `dbus`,
`chromedriver`, and `chromium` in one `supervisorctl` call, then probes
readiness concurrently. Per-service files (`chromium.go`, `display.go`,
`envoy.go`, `probes.go`, `supervisord.go`, `system.go`) keep each
concern isolated.
- **Phase C** (identity-bound) renders the envoy bootstrap from
`INST_NAME` / `JWT` / `XDS_SERVER` and brings up `kernel-images-api` +
envoy once those are present.
X11 socket readiness is a small shared package (`server/lib/x11`) used
by both the wrapper and the chromium launcher so they agree on what
"display ready" means.
Per-service tweaks:
- supervisor confs: `startsecs=2` → `0` so `supervisorctl start` returns
immediately; the Go wrapper probes readiness directly.
- `init-envoy.sh`: drop the trailing port poll / curl-through-proxy
check — `waitAllReady` covers both, and the script now fails fast on any
error.
- `Kraftfile` `cmd` updated from `/wrapper.sh` to `/wrapper`.
- Envoy proxy CA cert is baked at image build time.
Other behaviour:
- SIGTERM/SIGINT handler is registered before `supervisord` starts so
signals during the seconds-long startup window are caught instead of
killing the wrapper outright.
- Critical boot scripts (`init-envoy.sh`) are streamed via
`runStreamFatal` so failures abort boot instead of being silently
swallowed, matching the old `set -o errexit`.
- The ready log line reports per-probe durations, e.g. `ready in 2.6s
(phaseA=251ms phaseC=289ms; cdp=2.646s chromedriver=1.468s
forward-proxy=2.306s)`.
Cosmetic + non-critical work (`pulseaudio`, `--no-sandbox` infobar
dismissal) runs off the hot path.
## Test plan
- [ ] `go build ./cmd/wrapper` and `go vet ./cmd/wrapper` pass
- [ ] Build chromium-headless image and confirm container reaches
CDP-ready
- [ ] Build chromium-headful image and confirm container reaches
CDP-ready
- [ ] Confirm envoy comes up and the forward-proxy listener is reachable
when `INST_NAME` / `XDS_SERVER` / `KERNEL_INSTANCE_JWT` are set
- [ ] Confirm `RUN_AS_ROOT=true` headful flow still dismisses the
`--no-sandbox` infobar
- [ ] Confirm SIGTERM/SIGINT propagates to supervisord and child
services exit cleanly
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Medium Risk**
> Medium risk because it replaces the container entrypoint/startup
orchestration for both headful and headless Chromium images and changes
Envoy certificate/bootstrap behavior, which could affect boot readiness
and proxy trust in production.
>
> **Overview**
> **Replaces `wrapper.sh` with a single Go entrypoint (`/wrapper`)** for
both `chromium-headful` and `chromium-headless`, updating Dockerfiles,
Kraft `cmd`, and README examples to use the new binary.
>
> The new wrapper starts `supervisord` in foreground, brings up core
services in parallel (X server, `dbus`, `chromedriver`, `chromium`), and
performs explicit readiness probes (CDP, chromedriver, optional `neko`,
optional Envoy) instead of relying on `supervisor` delays; corresponding
supervisor `startsecs` values are set to `0`.
>
> **Envoy setup is split**: a new build-time
`shared/envoy/bake-certs.sh` bakes the forward-proxy CA into system
trust + NSS DBs, while `shared/envoy/init-envoy.sh` now only renders
bootstrap from identity env and starts/restarts Envoy (dropping runtime
cert generation and inline readiness/proxy tests). `chromium-launcher`
now waits for X display (and `mutter` when headful) using a new
`server/lib/x11` helper to avoid restart loops/WM decoration issues.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
ae4b8d3. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
---------
Co-authored-by: sjmiller609 <7516283+sjmiller609@users.noreply.github.com>
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>1 parent 7be1cc6 commit 452efe9
29 files changed
Lines changed: 858 additions & 730 deletions
File tree
- images
- chromium-headful
- supervisor/services
- chromium-headless/image
- supervisor/services
- server
- cmd
- chromium-launcher
- wrapper
- lib/x11
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
86 | | - | |
| 86 | + | |
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
30 | 36 | | |
31 | 37 | | |
32 | 38 | | |
| |||
356 | 362 | | |
357 | 363 | | |
358 | 364 | | |
359 | | - | |
360 | 365 | | |
361 | 366 | | |
362 | 367 | | |
| |||
373 | 378 | | |
374 | 379 | | |
375 | 380 | | |
| 381 | + | |
376 | 382 | | |
377 | 383 | | |
378 | 384 | | |
| |||
389 | 395 | | |
390 | 396 | | |
391 | 397 | | |
392 | | - | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
0 commit comments