Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
72 changes: 63 additions & 9 deletions Dockerfile.local
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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
Expand All @@ -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;
Copy link

Copilot AI Sep 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using sed to modify TypeScript configuration files is fragile and could break if the file format changes. Consider using a more robust configuration method or environment variables.

Suggested change
RUN sed -i 's/AUTOMATED_MODE: false/AUTOMATED_MODE: true/' front_end/panels/ai_chat/core/BuildConfig.ts;
RUN node -e "const fs = require('fs'); \
const path = 'front_end/panels/ai_chat/core/BuildConfig.ts'; \
let content = fs.readFileSync(path, 'utf8'); \
content = content.replace(/AUTOMATED_MODE:\\s*false/, 'AUTOMATED_MODE: true'); \
fs.writeFileSync(path, content);"

Copilot uses AI. Check for mistakes.

# 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need the platform definition here?

WORKDIR /workspace/server

ARG TARGETOS
Expand All @@ -67,19 +93,19 @@ 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} \
Copy link

Copilot AI Sep 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The GOARCH default is hardcoded to arm64 but the COPY commands and other stages use different platform defaults. This inconsistency could cause build issues on different architectures.

Copilot uses AI. Check for mistakes.
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
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; \
Expand All @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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 \
Expand All @@ -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" ]
16 changes: 11 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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..."
Expand Down Expand Up @@ -64,16 +65,20 @@ 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"
@echo " DevTools Health: http://localhost:8001/health"

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"
Expand All @@ -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"

Expand Down
4 changes: 2 additions & 2 deletions cloudrun-kernel-wrapper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 16 additions & 4 deletions run-local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,27 @@ 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
-e RUN_AS_ROOT="$RUN_AS_ROOT"
--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" )
Expand All @@ -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"
Copy link

Copilot AI Sep 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Changing from interactive mode (-it) to detached mode (-d) removes the ability to easily stop the container with Ctrl+C. This could make development workflow less convenient.

Suggested change
docker run -d "${RUN_ARGS[@]}" "$IMAGE"
# Allow user to override run mode (default: interactive)
DOCKER_RUN_MODE="${DOCKER_RUN_MODE:--it}"
echo "Running Docker container in mode: $DOCKER_RUN_MODE"
docker run $DOCKER_RUN_MODE "${RUN_ARGS[@]}" "$IMAGE"

Copilot uses AI. Check for mistakes.

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"
2 changes: 1 addition & 1 deletion supervisor-cloudrun/neko.conf
Original file line number Diff line number Diff line change
@@ -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
Expand Down
8 changes: 8 additions & 0 deletions supervisor/services/chromium.conf
Original file line number Diff line number Diff line change
@@ -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"
8 changes: 8 additions & 0 deletions supervisor/services/eval-server.conf
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions supervisor/services/neko.conf
Original file line number Diff line number Diff line change
@@ -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