Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions images/chromium-headless/image/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ RUN --mount=type=cache,target=/root/.cache/go-build,id=$CACHEIDPREFIX-go-build \
GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH:-amd64} \
go build -ldflags="-s -w" -o /out/chromium-launcher ./cmd/chromium-launcher

# Build CDP live view server
RUN --mount=type=cache,target=/root/.cache/go-build,id=$CACHEIDPREFIX-go-build \
--mount=type=cache,target=/go/pkg/mod,id=$CACHEIDPREFIX-go-pkg-mod \
GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH:-amd64} \
go build -ldflags="-s -w" -o /out/cdp-live-view ./cmd/cdp-live-view

FROM docker.io/ubuntu:22.04 AS ffmpeg-downloader

# Allow cross-compilation when building with BuildKit platforms
Expand Down Expand Up @@ -237,6 +243,7 @@ RUN chmod +x /usr/local/bin/init-envoy.sh
# Copy the kernel-images API binary built in the builder stage
COPY --from=server-builder /out/kernel-images-api /usr/local/bin/kernel-images-api
COPY --from=server-builder /out/chromium-launcher /usr/local/bin/chromium-launcher
COPY --from=server-builder /out/cdp-live-view /usr/local/bin/cdp-live-view

# Copy and compile the Playwright daemon
COPY server/runtime/playwright-daemon.ts /tmp/playwright-daemon.ts
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[program:cdp-live-view]
command=/usr/local/bin/cdp-live-view
autostart=false
autorestart=true
startsecs=2
stdout_logfile=/var/log/supervisord/cdp-live-view
redirect_stderr=true
7 changes: 7 additions & 0 deletions images/chromium-headless/image/wrapper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ cleanup () {
echo "[wrapper] Cleaning up..."
# Re-enable scale-to-zero if the script terminates early
enable_scale_to_zero
supervisorctl -c /etc/supervisor/supervisord.conf stop cdp-live-view || true
supervisorctl -c /etc/supervisor/supervisord.conf stop chromedriver || true
supervisorctl -c /etc/supervisor/supervisord.conf stop chromium || true
supervisorctl -c /etc/supervisor/supervisord.conf stop xvfb || true
Expand Down Expand Up @@ -274,6 +275,12 @@ echo "[wrapper] Starting ChromeDriver via supervisord"
supervisorctl -c /etc/supervisor/supervisord.conf start chromedriver
wait_for_tcp_port 127.0.0.1 9225 "ChromeDriver" 50 0.2 "10s" || true

if [[ "${ENABLE_LIVE_VIEW:-}" == "true" ]]; then
echo "[wrapper] Starting CDP live view via supervisord"
supervisorctl -c /etc/supervisor/supervisord.conf start cdp-live-view
wait_for_tcp_port 127.0.0.1 8080 "cdp-live-view" 50 0.2 "10s" || true
fi

echo "[wrapper] startup complete!"
# Re-enable scale-to-zero once startup has completed (when not under Docker)
if [[ -z "${WITHDOCKER:-}" ]]; then
Expand Down
2 changes: 2 additions & 0 deletions images/chromium-headless/run-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ RUN_ARGS=(
-p 9222:9222
-p 9224:9224
-p 444:10001
-p 8080:8080
-v "$HOST_RECORDINGS_DIR:/recordings"
-e ENABLE_LIVE_VIEW="${ENABLE_LIVE_VIEW:-true}"
Comment thread
cursor[bot] marked this conversation as resolved.
Outdated
)

if [[ -n "${PLAYWRIGHT_ENGINE:-}" ]]; then
Expand Down
4 changes: 4 additions & 0 deletions images/chromium-headless/run-unikernel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,8 @@ deploy_args=(
-n "$NAME"
)

if [[ "${ENABLE_LIVE_VIEW:-}" == "true" ]]; then
deploy_args+=( -e ENABLE_LIVE_VIEW=true -p 443:8080/http+tls )
fi

kraft cloud inst create "${deploy_args[@]}" "$IMAGE"
Loading
Loading