diff --git a/Dockerfile.local b/Dockerfile.local index fc46aac..92b4353 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,13 +50,38 @@ RUN git remote add upstream https://github.com/BrowserOperator/browser-operator- RUN git fetch upstream RUN git checkout upstream/main -# Build Browser Operator version +# Copy local changes from the repository (preserve build config) +# 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; + +# Build Browser Operator version with current changes RUN npm run build +# ============================================================================ +# Eval Server build stage +# ============================================================================ +FROM --platform=linux/arm64 node:18-alpine AS eval-server-builder + +WORKDIR /workspace + +# Copy local browser-operator-core eval server with our modifications +COPY browser-operator-core/eval-server/nodejs /workspace/eval-server + +WORKDIR /workspace/eval-server + +# Install dependencies +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 @@ -67,11 +93,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 @@ -79,7 +105,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; \ @@ -104,11 +130,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 @@ -235,6 +261,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 @@ -253,6 +282,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 +299,23 @@ 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/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 - && \ + 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 8081 8082 + ENTRYPOINT [ "/wrapper.sh" ] \ No newline at end of file diff --git a/Makefile b/Makefile index 7c9e9eb..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..." @@ -64,7 +65,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 +74,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 +93,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/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 75b8dc0..9c89adb 100755 --- a/run-local.sh +++ b/run-local.sh @@ -80,7 +80,11 @@ RUN_ARGS=( --memory 8192m -p 9222:9222 -p 444:10001 - -p 8001:8001 + -p 8000:8000 \ + -p 8001:8001 \ + -p 8080:8080 \ + -p 8081:8081 \ + -p 8082:8082 -e DISPLAY_NUM=1 -e HEIGHT=768 -e WIDTH=1024 @@ -88,10 +92,15 @@ 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" - RUN_ARGS+=( -p 8080:8080 ) RUN_ARGS+=( -e ENABLE_WEBRTC=true ) if [[ -n "${NEKO_ICESERVERS:-}" ]]; then RUN_ARGS+=( -e NEKO_ICESERVERS="$NEKO_ICESERVERS" ) @@ -104,11 +113,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:8080" +echo " WebRTC Client: http://localhost:8000" +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 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 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