From ba98adef903c9b85ad16de947b45e36d285d51c3 Mon Sep 17 00:00:00 2001 From: Oleh Luchkiv Date: Fri, 12 Sep 2025 11:32:39 -0500 Subject: [PATCH 1/7] Initial local API setup --- Dockerfile.local | 56 ++++++++++++++++++++++++++++++++++++++++++++++++ Makefile | 13 +++++++---- run-local.sh | 8 ++++--- 3 files changed, 70 insertions(+), 7 deletions(-) diff --git a/Dockerfile.local b/Dockerfile.local index fc46aac..c4fe972 100644 --- a/Dockerfile.local +++ b/Dockerfile.local @@ -52,6 +52,34 @@ RUN git checkout upstream/main # Build Browser Operator version RUN npm run build +# Enable automation mode by default +ARG AUTOMATED_MODE=true +RUN if [ "$AUTOMATED_MODE" = "true" ]; then \ + sed -i 's/AUTOMATED_MODE: false/AUTOMATED_MODE: true/' \ + front_end/panels/ai_chat/core/BuildConfig.ts; \ + fi + +# Rebuild with automation mode enabled +RUN if [ "$AUTOMATED_MODE" = "true" ]; then \ + npm run build; \ + fi + +# ============================================================================ +# Eval Server build stage +# ============================================================================ +FROM --platform=linux/amd64 node:18-alpine AS eval-server-builder + +WORKDIR /workspace + +# Clone browser-operator-core to get eval server +RUN apk add --no-cache git +RUN git clone https://github.com/BrowserOperator/browser-operator-core.git + +WORKDIR /workspace/browser-operator-core/eval-server/nodejs + +# Install dependencies +RUN npm install + # ============================================================================ # Use kernel-images base with DevTools integration # ============================================================================ @@ -253,6 +281,12 @@ RUN ln -s /etc/nginx/sites-available/devtools /etc/nginx/sites-enabled/devtools # Add DevTools nginx service to supervisor COPY supervisor/services/nginx-devtools.conf /etc/supervisor/conf.d/services/nginx-devtools.conf +# Add eval server service to supervisor +COPY supervisor/services/eval-server.conf /etc/supervisor/conf.d/services/eval-server.conf + +# Add neko service to supervisor (configured for port 8000) +COPY supervisor/services/neko.conf /etc/supervisor/conf.d/services/neko.conf + # Create nginx temp directories and set permissions RUN mkdir -p /var/lib/nginx/body \ /var/lib/nginx/proxy \ @@ -264,4 +298,26 @@ RUN mkdir -p /var/lib/nginx/body \ RUN useradd -m -s /bin/bash kernel +# ============================================================================ +# Eval Server Integration +# ============================================================================ + +# Copy eval server from builder +COPY --from=eval-server-builder /workspace/browser-operator-core/eval-server/nodejs /opt/eval-server + +# Copy local with-http-wrapper.js to override the default one +COPY with-http-wrapper.js /opt/eval-server/examples/with-http-wrapper.js + +# Install Node.js in final image for eval server +RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && \ + apt-get install -y nodejs && \ + rm -rf /var/lib/apt/lists/* + +# Create eval server startup script +RUN echo '#!/bin/bash\ncd /opt/eval-server && node examples/with-http-wrapper.js' > /usr/local/bin/start-eval-server.sh && \ + chmod +x /usr/local/bin/start-eval-server.sh + +# Expose ports +EXPOSE 8000 8001 8080 + ENTRYPOINT [ "/wrapper.sh" ] \ No newline at end of file diff --git a/Makefile b/Makefile index 7c9e9eb..9963cea 100644 --- a/Makefile +++ b/Makefile @@ -64,7 +64,8 @@ shell: ## Get shell access to running container info: ## Show connection information @echo "" @echo "๐ŸŒ Service Access Points:" - @echo " WebRTC Client: http://localhost:8080" + @echo " WebRTC Client: http://localhost:8000" + @echo " Eval Server API: http://localhost:8081" @echo " Chrome DevTools: http://localhost:9222/json" @echo " Recording API: http://localhost:444/api" @echo " Enhanced DevTools UI: http://localhost:8001" @@ -72,8 +73,11 @@ info: ## Show connection information test: ## Test service endpoints @echo "๐Ÿงช Testing service endpoints..." - @echo -n "WebRTC Client (8080): " - @curl -s -o /dev/null -w "%{http_code}" http://localhost:8080/ || echo "Failed to connect" + @echo -n "WebRTC Client (8000): " + @curl -s -o /dev/null -w "%{http_code}" http://localhost:8000/ || echo "Failed to connect" + @echo "" + @echo -n "Eval Server API (8081): " + @curl -s -o /dev/null -w "%{http_code}" http://localhost:8081/ || echo "Failed to connect" @echo "" @echo -n "Chrome DevTools (9222): " @curl -s -o /dev/null -w "%{http_code}" http://localhost:9222/json/version || echo "Failed to connect" @@ -88,7 +92,8 @@ test: ## Test service endpoints @curl -s -o /dev/null -w "%{http_code}" http://localhost:8001/health || echo "Failed to connect" @echo "" @echo "๐ŸŽฏ All services are ready! Access points:" - @echo " WebRTC Client: http://localhost:8080" + @echo " WebRTC Client: http://localhost:8000" + @echo " Eval Server API: http://localhost:8081" @echo " Chrome DevTools: http://localhost:9222/json" @echo " Enhanced DevTools UI: http://localhost:8001" diff --git a/run-local.sh b/run-local.sh index 75b8dc0..791e1ed 100755 --- a/run-local.sh +++ b/run-local.sh @@ -80,7 +80,9 @@ RUN_ARGS=( --memory 8192m -p 9222:9222 -p 444:10001 - -p 8001:8001 + -p 8000:8000 \ + -p 8001:8001 \ + -p 8081:8081 -e DISPLAY_NUM=1 -e HEIGHT=768 -e WIDTH=1024 @@ -91,7 +93,6 @@ RUN_ARGS=( # WebRTC port mapping if [[ "${ENABLE_WEBRTC:-}" == "true" ]]; then echo "Running container with WebRTC" - RUN_ARGS+=( -p 8080:8080 ) RUN_ARGS+=( -e ENABLE_WEBRTC=true ) if [[ -n "${NEKO_ICESERVERS:-}" ]]; then RUN_ARGS+=( -e NEKO_ICESERVERS="$NEKO_ICESERVERS" ) @@ -108,7 +109,8 @@ docker run -it "${RUN_ARGS[@]}" "$IMAGE" echo "" echo "๐ŸŒ Extended service should be accessible at:" -echo " WebRTC Client: http://localhost:8080" +echo " WebRTC Client: http://localhost:8000" +echo " Eval Server API: http://localhost:8081" echo " Chrome DevTools: http://localhost:9222" echo " Recording API: http://localhost:444" echo " Enhanced DevTools UI: http://localhost:8001" \ No newline at end of file From d147263cd8bcea00b8054ab42875906a701d9688 Mon Sep 17 00:00:00 2001 From: Oleh Luchkiv Date: Sat, 13 Sep 2025 10:24:18 -0500 Subject: [PATCH 2/7] Build works. TODO: eval connection --- Dockerfile.local | 44 ++++++++++++++++++++------------------------ 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/Dockerfile.local b/Dockerfile.local index c4fe972..2829097 100644 --- a/Dockerfile.local +++ b/Dockerfile.local @@ -4,7 +4,7 @@ # DevTools Frontend build stage using browser-operator-core FROM --platform=linux/amd64 ubuntu:22.04 AS devtools-builder -# Install required packages for DevTools frontend build +# Install required packages RUN apt-get update && apt-get install -y \ curl \ git \ @@ -30,7 +30,8 @@ RUN git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git ENV PATH="/workspace/depot_tools:${PATH}" ENV DEPOT_TOOLS_UPDATE=0 -# Follow README instructions exactly - fetching code +# Follow README instructions exactly: +# fetching code RUN mkdir devtools WORKDIR /workspace/devtools RUN fetch devtools-frontend @@ -49,25 +50,23 @@ RUN git remote add upstream https://github.com/BrowserOperator/browser-operator- RUN git fetch upstream RUN git checkout upstream/main -# Build Browser Operator version -RUN npm run build +# Copy local changes from the repository (preserve build config) +# Copy only the modified parts to avoid build conflicts +COPY browser-operator-core/front_end/core /workspace/devtools/devtools-frontend/front_end/core/ +COPY browser-operator-core/front_end/panels/ai_chat /workspace/devtools/devtools-frontend/front_end/panels/ai_chat/ +COPY browser-operator-core/front_end/entrypoints /workspace/devtools/devtools-frontend/front_end/entrypoints/ +COPY browser-operator-core/scripts /workspace/devtools/devtools-frontend/scripts/ -# Enable automation mode by default -ARG AUTOMATED_MODE=true -RUN if [ "$AUTOMATED_MODE" = "true" ]; then \ - sed -i 's/AUTOMATED_MODE: false/AUTOMATED_MODE: true/' \ - front_end/panels/ai_chat/core/BuildConfig.ts; \ - fi +# Force automated mode +RUN sed -i 's/AUTOMATED_MODE: false/AUTOMATED_MODE: true/' front_end/panels/ai_chat/core/BuildConfig.ts; -# Rebuild with automation mode enabled -RUN if [ "$AUTOMATED_MODE" = "true" ]; then \ - npm run build; \ - fi +# Build Browser Operator version with current changes +RUN npm run build # ============================================================================ # Eval Server build stage # ============================================================================ -FROM --platform=linux/amd64 node:18-alpine AS eval-server-builder +FROM --platform=linux/arm64 node:18-alpine AS eval-server-builder WORKDIR /workspace @@ -83,7 +82,7 @@ RUN npm install # ============================================================================ # Use kernel-images base with DevTools integration # ============================================================================ -FROM docker.io/golang:1.25.0 AS server-builder +FROM --platform=linux/arm64 docker.io/golang:1.25.0 AS server-builder WORKDIR /workspace/server ARG TARGETOS @@ -95,11 +94,11 @@ COPY kernel-images/server/go.sum ./ RUN go mod download COPY kernel-images/server/ . -RUN GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH:-amd64} \ +RUN GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH:-arm64} \ go build -ldflags="-s -w" -o /out/kernel-images-api ./cmd/api # webrtc client -FROM node:22-bullseye-slim AS client +FROM --platform=linux/arm64 node:22-bullseye-slim AS client WORKDIR /src COPY kernel-images/images/chromium-headful/client/package*.json ./ RUN npm install @@ -107,7 +106,7 @@ COPY kernel-images/images/chromium-headful/client/ . RUN npm run build # xorg dependencies -FROM docker.io/ubuntu:22.04 AS xorg-deps +FROM --platform=linux/arm64 docker.io/ubuntu:22.04 AS xorg-deps WORKDIR /xorg ENV DEBIAN_FRONTEND=noninteractive RUN set -eux; \ @@ -132,11 +131,11 @@ RUN set -eux; \ make -j$(nproc); \ make install; -FROM ghcr.io/onkernel/neko/base:3.0.6-v1.0.1 AS neko +FROM --platform=linux/arm64 ghcr.io/onkernel/neko/base:3.0.6-v1.0.1 AS neko # ^--- now has event.SYSTEM_PONG with legacy support to keepalive # Final stage: kernel-images base + DevTools static files -FROM docker.io/ubuntu:22.04 +FROM --platform=linux/arm64 docker.io/ubuntu:22.04 ENV DEBIAN_FRONTEND=noninteractive ENV DEBIAN_PRIORITY=high @@ -305,9 +304,6 @@ RUN useradd -m -s /bin/bash kernel # Copy eval server from builder COPY --from=eval-server-builder /workspace/browser-operator-core/eval-server/nodejs /opt/eval-server -# Copy local with-http-wrapper.js to override the default one -COPY with-http-wrapper.js /opt/eval-server/examples/with-http-wrapper.js - # Install Node.js in final image for eval server RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && \ apt-get install -y nodejs && \ From 2fca6f6e9ed927e70d9fbf25310d436bf560216a Mon Sep 17 00:00:00 2001 From: Oleh Luchkiv Date: Sat, 13 Sep 2025 12:55:16 -0500 Subject: [PATCH 3/7] Extra files for the build --- supervisor/services/eval-server.conf | 8 ++++++++ supervisor/services/neko.conf | 8 ++++++++ 2 files changed, 16 insertions(+) create mode 100644 supervisor/services/eval-server.conf create mode 100644 supervisor/services/neko.conf diff --git a/supervisor/services/eval-server.conf b/supervisor/services/eval-server.conf new file mode 100644 index 0000000..530f00d --- /dev/null +++ b/supervisor/services/eval-server.conf @@ -0,0 +1,8 @@ +[program:eval-server] +command=/usr/local/bin/start-eval-server.sh +autostart=true +autorestart=true +stdout_logfile=/var/log/supervisor/eval-server.log +stderr_logfile=/var/log/supervisor/eval-server.error.log +environment=NODE_ENV="production" +priority=30 \ No newline at end of file diff --git a/supervisor/services/neko.conf b/supervisor/services/neko.conf new file mode 100644 index 0000000..a8b9fc8 --- /dev/null +++ b/supervisor/services/neko.conf @@ -0,0 +1,8 @@ +[program:neko] +command=/usr/bin/neko serve --bind 0.0.0.0:8000 --config /etc/neko/neko.yaml --static /var/www +autostart=true +autorestart=true +stdout_logfile=/var/log/supervisor/neko.log +stderr_logfile=/var/log/supervisor/neko.error.log +environment=DISPLAY=":1.0",HOME="/root" +priority=20 \ No newline at end of file From 81774336f2b7f2a77a5e90881753e6d7c6550cff Mon Sep 17 00:00:00 2001 From: Oleh Luchkiv Date: Mon, 15 Sep 2025 17:24:08 -0500 Subject: [PATCH 4/7] Start chromium with devtools panel --- Dockerfile.local | 3 +++ supervisor/services/chromium.conf | 8 ++++++++ 2 files changed, 11 insertions(+) create mode 100644 supervisor/services/chromium.conf diff --git a/Dockerfile.local b/Dockerfile.local index 2829097..0183737 100644 --- a/Dockerfile.local +++ b/Dockerfile.local @@ -262,6 +262,9 @@ COPY kernel-images/images/chromium-headful/wrapper.sh /wrapper.sh COPY kernel-images/images/chromium-headful/supervisord.conf /etc/supervisor/supervisord.conf COPY kernel-images/images/chromium-headful/supervisor/services/ /etc/supervisor/conf.d/services/ +# Override chromium.conf with local version that includes auto-open-devtools +COPY supervisor/services/chromium.conf /etc/supervisor/conf.d/services/chromium.conf + # 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 diff --git a/supervisor/services/chromium.conf b/supervisor/services/chromium.conf new file mode 100644 index 0000000..12b9fd7 --- /dev/null +++ b/supervisor/services/chromium.conf @@ -0,0 +1,8 @@ +[program:chromium] +command=/bin/bash -lc '/images/chromium-headful/start-chromium.sh' +autostart=false +autorestart=true +startsecs=5 +stdout_logfile=/var/log/supervisord/chromium +redirect_stderr=true +environment=HOME="/home/kernel",USER="kernel",CHROMIUM_FLAGS="--auto-open-devtools-for-tabs" \ No newline at end of file From a5fca113287ac123d54e20e7e2025e01e4000231 Mon Sep 17 00:00:00 2001 From: Oleh Luchkiv Date: Tue, 16 Sep 2025 04:48:16 -0500 Subject: [PATCH 5/7] Eval-server connects to the AI panel --- Dockerfile.local | 11 +++++------ cloudrun-kernel-wrapper.sh | 4 ++-- run-local.sh | 10 +++++++--- supervisor-cloudrun/neko.conf | 2 +- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/Dockerfile.local b/Dockerfile.local index 0183737..c1ca6c8 100644 --- a/Dockerfile.local +++ b/Dockerfile.local @@ -70,11 +70,10 @@ FROM --platform=linux/arm64 node:18-alpine AS eval-server-builder WORKDIR /workspace -# Clone browser-operator-core to get eval server -RUN apk add --no-cache git -RUN git clone https://github.com/BrowserOperator/browser-operator-core.git +# Copy local browser-operator-core eval server with our modifications +COPY browser-operator-core/eval-server/nodejs /workspace/eval-server -WORKDIR /workspace/browser-operator-core/eval-server/nodejs +WORKDIR /workspace/eval-server # Install dependencies RUN npm install @@ -305,7 +304,7 @@ RUN useradd -m -s /bin/bash kernel # ============================================================================ # Copy eval server from builder -COPY --from=eval-server-builder /workspace/browser-operator-core/eval-server/nodejs /opt/eval-server +COPY --from=eval-server-builder /workspace/eval-server /opt/eval-server # Install Node.js in final image for eval server RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && \ @@ -317,6 +316,6 @@ RUN echo '#!/bin/bash\ncd /opt/eval-server && node examples/with-http-wrapper.js chmod +x /usr/local/bin/start-eval-server.sh # Expose ports -EXPOSE 8000 8001 8080 +EXPOSE 8000 8001 8080 8081 8082 ENTRYPOINT [ "/wrapper.sh" ] \ No newline at end of file diff --git a/cloudrun-kernel-wrapper.sh b/cloudrun-kernel-wrapper.sh index a6f7b92..f660127 100644 --- a/cloudrun-kernel-wrapper.sh +++ b/cloudrun-kernel-wrapper.sh @@ -92,8 +92,8 @@ done if [[ "${ENABLE_WEBRTC:-}" == "true" ]]; then echo "[cloudrun-kernel] Starting Neko (WebRTC)..." supervisorctl -c /etc/supervisor/supervisord-cloudrun.conf start neko - echo "[cloudrun-kernel] Waiting for Neko on port 8080..." - while ! nc -z 127.0.0.1 8080 2>/dev/null; do + echo "[cloudrun-kernel] Waiting for Neko on port 8081..." + while ! nc -z 127.0.0.1 8081 2>/dev/null; do sleep 0.5 done fi diff --git a/run-local.sh b/run-local.sh index 791e1ed..13653c4 100755 --- a/run-local.sh +++ b/run-local.sh @@ -82,7 +82,9 @@ RUN_ARGS=( -p 444:10001 -p 8000:8000 \ -p 8001:8001 \ - -p 8081:8081 + -p 8080:8080 \ + -p 8081:8081 \ + -p 8082:8082 -e DISPLAY_NUM=1 -e HEIGHT=768 -e WIDTH=1024 @@ -105,12 +107,14 @@ fi # Run with our additional DevTools port mapping docker rm -f "$NAME" 2>/dev/null || true -docker run -it "${RUN_ARGS[@]}" "$IMAGE" +docker run -d "${RUN_ARGS[@]}" "$IMAGE" echo "" echo "๐ŸŒ Extended service should be accessible at:" echo " WebRTC Client: http://localhost:8000" -echo " Eval Server API: http://localhost:8081" +echo " Eval Server HTTP API: http://localhost:8080" +echo " WebRTC (Neko): http://localhost:8081" +echo " Eval Server WS: ws://localhost:8082" echo " Chrome DevTools: http://localhost:9222" echo " Recording API: http://localhost:444" echo " Enhanced DevTools UI: http://localhost:8001" \ No newline at end of file diff --git a/supervisor-cloudrun/neko.conf b/supervisor-cloudrun/neko.conf index a97169d..d74bf00 100644 --- a/supervisor-cloudrun/neko.conf +++ b/supervisor-cloudrun/neko.conf @@ -1,5 +1,5 @@ [program:neko] -command=/usr/bin/neko serve --server.static /var/www --server.bind 0.0.0.0:8080 +command=/usr/bin/neko serve --server.static /var/www --server.bind 0.0.0.0:8081 user=kernel autostart=false autorestart=true From 2621deca4bcdd97aa2b1428e8131c303abe942b0 Mon Sep 17 00:00:00 2001 From: Oleh Luchkiv Date: Wed, 24 Sep 2025 09:52:37 -0500 Subject: [PATCH 6/7] Added commented lines for local development --- Dockerfile.local | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Dockerfile.local b/Dockerfile.local index c1ca6c8..92b4353 100644 --- a/Dockerfile.local +++ b/Dockerfile.local @@ -51,11 +51,11 @@ RUN git fetch upstream RUN git checkout upstream/main # Copy local changes from the repository (preserve build config) -# Copy only the modified parts to avoid build conflicts -COPY browser-operator-core/front_end/core /workspace/devtools/devtools-frontend/front_end/core/ -COPY browser-operator-core/front_end/panels/ai_chat /workspace/devtools/devtools-frontend/front_end/panels/ai_chat/ -COPY browser-operator-core/front_end/entrypoints /workspace/devtools/devtools-frontend/front_end/entrypoints/ -COPY browser-operator-core/scripts /workspace/devtools/devtools-frontend/scripts/ +# Uncomment the following lines if you want to copy local changes +# COPY browser-operator-core/front_end/core /workspace/devtools/devtools-frontend/front_end/core/ +# COPY browser-operator-core/front_end/panels/ai_chat /workspace/devtools/devtools-frontend/front_end/panels/ai_chat/ +# COPY browser-operator-core/front_end/entrypoints /workspace/devtools/devtools-frontend/front_end/entrypoints/ +# COPY browser-operator-core/scripts /workspace/devtools/devtools-frontend/scripts/ # Force automated mode RUN sed -i 's/AUTOMATED_MODE: false/AUTOMATED_MODE: true/' front_end/panels/ai_chat/core/BuildConfig.ts; From 6f892ab318296fe21501aff56dcc2829b5552e56 Mon Sep 17 00:00:00 2001 From: Oleh Luchkiv Date: Wed, 24 Sep 2025 15:41:56 -0500 Subject: [PATCH 7/7] Added possibility to pass multiple URLs for multiple tabs --- Makefile | 3 ++- run-local.sh | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 9963cea..2e640e0 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,8 @@ build: init ## Build extended image with DevTools frontend run: ## Run extended container with DevTools (interactive) @echo "๐Ÿš€ Starting extended kernel-browser with DevTools..." - ./run-local.sh + @if [ -n "$(URLS)" ]; then echo "๐Ÿ“„ Opening URLs: $(URLS)"; fi + URLS='$(URLS)' ./run-local.sh compose-up: build ## Start with docker-compose (background) @echo "๐Ÿš€ Starting with docker-compose..." diff --git a/run-local.sh b/run-local.sh index 13653c4..9c89adb 100755 --- a/run-local.sh +++ b/run-local.sh @@ -92,6 +92,12 @@ RUN_ARGS=( --mount type=bind,src="$FLAGS_FILE",dst=/chromium/flags,ro ) +# Add URLS environment variable if provided +if [[ -n "${URLS:-}" ]]; then + echo " URLs: $URLS" + RUN_ARGS+=( -e URLS="$URLS" ) +fi + # WebRTC port mapping if [[ "${ENABLE_WEBRTC:-}" == "true" ]]; then echo "Running container with WebRTC"