Skip to content

Commit fe643ef

Browse files
authored
Merge pull request #6 from BrowserOperator/feat/local-eval-api-try3
Local Dockerised Eval Server
2 parents 66272a4 + 6f892ab commit fe643ef

File tree

8 files changed

+117
-21
lines changed

8 files changed

+117
-21
lines changed

Dockerfile.local

Lines changed: 63 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# DevTools Frontend build stage using browser-operator-core
55
FROM --platform=linux/amd64 ubuntu:22.04 AS devtools-builder
66

7-
# Install required packages for DevTools frontend build
7+
# Install required packages
88
RUN apt-get update && apt-get install -y \
99
curl \
1010
git \
@@ -30,7 +30,8 @@ RUN git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
3030
ENV PATH="/workspace/depot_tools:${PATH}"
3131
ENV DEPOT_TOOLS_UPDATE=0
3232

33-
# Follow README instructions exactly - fetching code
33+
# Follow README instructions exactly:
34+
# fetching code
3435
RUN mkdir devtools
3536
WORKDIR /workspace/devtools
3637
RUN fetch devtools-frontend
@@ -49,13 +50,38 @@ RUN git remote add upstream https://github.com/BrowserOperator/browser-operator-
4950
RUN git fetch upstream
5051
RUN git checkout upstream/main
5152

52-
# Build Browser Operator version
53+
# Copy local changes from the repository (preserve build config)
54+
# Uncomment the following lines if you want to copy local changes
55+
# COPY browser-operator-core/front_end/core /workspace/devtools/devtools-frontend/front_end/core/
56+
# COPY browser-operator-core/front_end/panels/ai_chat /workspace/devtools/devtools-frontend/front_end/panels/ai_chat/
57+
# COPY browser-operator-core/front_end/entrypoints /workspace/devtools/devtools-frontend/front_end/entrypoints/
58+
# COPY browser-operator-core/scripts /workspace/devtools/devtools-frontend/scripts/
59+
60+
# Force automated mode
61+
RUN sed -i 's/AUTOMATED_MODE: false/AUTOMATED_MODE: true/' front_end/panels/ai_chat/core/BuildConfig.ts;
62+
63+
# Build Browser Operator version with current changes
5364
RUN npm run build
5465

66+
# ============================================================================
67+
# Eval Server build stage
68+
# ============================================================================
69+
FROM --platform=linux/arm64 node:18-alpine AS eval-server-builder
70+
71+
WORKDIR /workspace
72+
73+
# Copy local browser-operator-core eval server with our modifications
74+
COPY browser-operator-core/eval-server/nodejs /workspace/eval-server
75+
76+
WORKDIR /workspace/eval-server
77+
78+
# Install dependencies
79+
RUN npm install
80+
5581
# ============================================================================
5682
# Use kernel-images base with DevTools integration
5783
# ============================================================================
58-
FROM docker.io/golang:1.25.0 AS server-builder
84+
FROM --platform=linux/arm64 docker.io/golang:1.25.0 AS server-builder
5985
WORKDIR /workspace/server
6086

6187
ARG TARGETOS
@@ -67,19 +93,19 @@ COPY kernel-images/server/go.sum ./
6793
RUN go mod download
6894

6995
COPY kernel-images/server/ .
70-
RUN GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH:-amd64} \
96+
RUN GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH:-arm64} \
7197
go build -ldflags="-s -w" -o /out/kernel-images-api ./cmd/api
7298

7399
# webrtc client
74-
FROM node:22-bullseye-slim AS client
100+
FROM --platform=linux/arm64 node:22-bullseye-slim AS client
75101
WORKDIR /src
76102
COPY kernel-images/images/chromium-headful/client/package*.json ./
77103
RUN npm install
78104
COPY kernel-images/images/chromium-headful/client/ .
79105
RUN npm run build
80106

81107
# xorg dependencies
82-
FROM docker.io/ubuntu:22.04 AS xorg-deps
108+
FROM --platform=linux/arm64 docker.io/ubuntu:22.04 AS xorg-deps
83109
WORKDIR /xorg
84110
ENV DEBIAN_FRONTEND=noninteractive
85111
RUN set -eux; \
@@ -104,11 +130,11 @@ RUN set -eux; \
104130
make -j$(nproc); \
105131
make install;
106132

107-
FROM ghcr.io/onkernel/neko/base:3.0.6-v1.0.1 AS neko
133+
FROM --platform=linux/arm64 ghcr.io/onkernel/neko/base:3.0.6-v1.0.1 AS neko
108134
# ^--- now has event.SYSTEM_PONG with legacy support to keepalive
109135

110136
# Final stage: kernel-images base + DevTools static files
111-
FROM docker.io/ubuntu:22.04
137+
FROM --platform=linux/arm64 docker.io/ubuntu:22.04
112138

113139
ENV DEBIAN_FRONTEND=noninteractive
114140
ENV DEBIAN_PRIORITY=high
@@ -235,6 +261,9 @@ COPY kernel-images/images/chromium-headful/wrapper.sh /wrapper.sh
235261
COPY kernel-images/images/chromium-headful/supervisord.conf /etc/supervisor/supervisord.conf
236262
COPY kernel-images/images/chromium-headful/supervisor/services/ /etc/supervisor/conf.d/services/
237263

264+
# Override chromium.conf with local version that includes auto-open-devtools
265+
COPY supervisor/services/chromium.conf /etc/supervisor/conf.d/services/chromium.conf
266+
238267
# copy the kernel-images API binary built in the builder stage
239268
COPY --from=server-builder /out/kernel-images-api /usr/local/bin/kernel-images-api
240269

@@ -253,6 +282,12 @@ RUN ln -s /etc/nginx/sites-available/devtools /etc/nginx/sites-enabled/devtools
253282
# Add DevTools nginx service to supervisor
254283
COPY supervisor/services/nginx-devtools.conf /etc/supervisor/conf.d/services/nginx-devtools.conf
255284

285+
# Add eval server service to supervisor
286+
COPY supervisor/services/eval-server.conf /etc/supervisor/conf.d/services/eval-server.conf
287+
288+
# Add neko service to supervisor (configured for port 8000)
289+
COPY supervisor/services/neko.conf /etc/supervisor/conf.d/services/neko.conf
290+
256291
# Create nginx temp directories and set permissions
257292
RUN mkdir -p /var/lib/nginx/body \
258293
/var/lib/nginx/proxy \
@@ -264,4 +299,23 @@ RUN mkdir -p /var/lib/nginx/body \
264299

265300
RUN useradd -m -s /bin/bash kernel
266301

302+
# ============================================================================
303+
# Eval Server Integration
304+
# ============================================================================
305+
306+
# Copy eval server from builder
307+
COPY --from=eval-server-builder /workspace/eval-server /opt/eval-server
308+
309+
# Install Node.js in final image for eval server
310+
RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && \
311+
apt-get install -y nodejs && \
312+
rm -rf /var/lib/apt/lists/*
313+
314+
# Create eval server startup script
315+
RUN echo '#!/bin/bash\ncd /opt/eval-server && node examples/with-http-wrapper.js' > /usr/local/bin/start-eval-server.sh && \
316+
chmod +x /usr/local/bin/start-eval-server.sh
317+
318+
# Expose ports
319+
EXPOSE 8000 8001 8080 8081 8082
320+
267321
ENTRYPOINT [ "/wrapper.sh" ]

Makefile

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ build: init ## Build extended image with DevTools frontend
2222

2323
run: ## Run extended container with DevTools (interactive)
2424
@echo "🚀 Starting extended kernel-browser with DevTools..."
25-
./run-local.sh
25+
@if [ -n "$(URLS)" ]; then echo "📄 Opening URLs: $(URLS)"; fi
26+
URLS='$(URLS)' ./run-local.sh
2627

2728
compose-up: build ## Start with docker-compose (background)
2829
@echo "🚀 Starting with docker-compose..."
@@ -64,16 +65,20 @@ shell: ## Get shell access to running container
6465
info: ## Show connection information
6566
@echo ""
6667
@echo "🌐 Service Access Points:"
67-
@echo " WebRTC Client: http://localhost:8080"
68+
@echo " WebRTC Client: http://localhost:8000"
69+
@echo " Eval Server API: http://localhost:8081"
6870
@echo " Chrome DevTools: http://localhost:9222/json"
6971
@echo " Recording API: http://localhost:444/api"
7072
@echo " Enhanced DevTools UI: http://localhost:8001"
7173
@echo " DevTools Health: http://localhost:8001/health"
7274

7375
test: ## Test service endpoints
7476
@echo "🧪 Testing service endpoints..."
75-
@echo -n "WebRTC Client (8080): "
76-
@curl -s -o /dev/null -w "%{http_code}" http://localhost:8080/ || echo "Failed to connect"
77+
@echo -n "WebRTC Client (8000): "
78+
@curl -s -o /dev/null -w "%{http_code}" http://localhost:8000/ || echo "Failed to connect"
79+
@echo ""
80+
@echo -n "Eval Server API (8081): "
81+
@curl -s -o /dev/null -w "%{http_code}" http://localhost:8081/ || echo "Failed to connect"
7782
@echo ""
7883
@echo -n "Chrome DevTools (9222): "
7984
@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
8893
@curl -s -o /dev/null -w "%{http_code}" http://localhost:8001/health || echo "Failed to connect"
8994
@echo ""
9095
@echo "🎯 All services are ready! Access points:"
91-
@echo " WebRTC Client: http://localhost:8080"
96+
@echo " WebRTC Client: http://localhost:8000"
97+
@echo " Eval Server API: http://localhost:8081"
9298
@echo " Chrome DevTools: http://localhost:9222/json"
9399
@echo " Enhanced DevTools UI: http://localhost:8001"
94100

cloudrun-kernel-wrapper.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ done
9292
if [[ "${ENABLE_WEBRTC:-}" == "true" ]]; then
9393
echo "[cloudrun-kernel] Starting Neko (WebRTC)..."
9494
supervisorctl -c /etc/supervisor/supervisord-cloudrun.conf start neko
95-
echo "[cloudrun-kernel] Waiting for Neko on port 8080..."
96-
while ! nc -z 127.0.0.1 8080 2>/dev/null; do
95+
echo "[cloudrun-kernel] Waiting for Neko on port 8081..."
96+
while ! nc -z 127.0.0.1 8081 2>/dev/null; do
9797
sleep 0.5
9898
done
9999
fi

run-local.sh

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,18 +80,27 @@ RUN_ARGS=(
8080
--memory 8192m
8181
-p 9222:9222
8282
-p 444:10001
83-
-p 8001:8001
83+
-p 8000:8000 \
84+
-p 8001:8001 \
85+
-p 8080:8080 \
86+
-p 8081:8081 \
87+
-p 8082:8082
8488
-e DISPLAY_NUM=1
8589
-e HEIGHT=768
8690
-e WIDTH=1024
8791
-e RUN_AS_ROOT="$RUN_AS_ROOT"
8892
--mount type=bind,src="$FLAGS_FILE",dst=/chromium/flags,ro
8993
)
9094

95+
# Add URLS environment variable if provided
96+
if [[ -n "${URLS:-}" ]]; then
97+
echo " URLs: $URLS"
98+
RUN_ARGS+=( -e URLS="$URLS" )
99+
fi
100+
91101
# WebRTC port mapping
92102
if [[ "${ENABLE_WEBRTC:-}" == "true" ]]; then
93103
echo "Running container with WebRTC"
94-
RUN_ARGS+=( -p 8080:8080 )
95104
RUN_ARGS+=( -e ENABLE_WEBRTC=true )
96105
if [[ -n "${NEKO_ICESERVERS:-}" ]]; then
97106
RUN_ARGS+=( -e NEKO_ICESERVERS="$NEKO_ICESERVERS" )
@@ -104,11 +113,14 @@ fi
104113

105114
# Run with our additional DevTools port mapping
106115
docker rm -f "$NAME" 2>/dev/null || true
107-
docker run -it "${RUN_ARGS[@]}" "$IMAGE"
116+
docker run -d "${RUN_ARGS[@]}" "$IMAGE"
108117

109118
echo ""
110119
echo "🌐 Extended service should be accessible at:"
111-
echo " WebRTC Client: http://localhost:8080"
120+
echo " WebRTC Client: http://localhost:8000"
121+
echo " Eval Server HTTP API: http://localhost:8080"
122+
echo " WebRTC (Neko): http://localhost:8081"
123+
echo " Eval Server WS: ws://localhost:8082"
112124
echo " Chrome DevTools: http://localhost:9222"
113125
echo " Recording API: http://localhost:444"
114126
echo " Enhanced DevTools UI: http://localhost:8001"

supervisor-cloudrun/neko.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[program:neko]
2-
command=/usr/bin/neko serve --server.static /var/www --server.bind 0.0.0.0:8080
2+
command=/usr/bin/neko serve --server.static /var/www --server.bind 0.0.0.0:8081
33
user=kernel
44
autostart=false
55
autorestart=true

supervisor/services/chromium.conf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[program:chromium]
2+
command=/bin/bash -lc '/images/chromium-headful/start-chromium.sh'
3+
autostart=false
4+
autorestart=true
5+
startsecs=5
6+
stdout_logfile=/var/log/supervisord/chromium
7+
redirect_stderr=true
8+
environment=HOME="/home/kernel",USER="kernel",CHROMIUM_FLAGS="--auto-open-devtools-for-tabs"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[program:eval-server]
2+
command=/usr/local/bin/start-eval-server.sh
3+
autostart=true
4+
autorestart=true
5+
stdout_logfile=/var/log/supervisor/eval-server.log
6+
stderr_logfile=/var/log/supervisor/eval-server.error.log
7+
environment=NODE_ENV="production"
8+
priority=30

supervisor/services/neko.conf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[program:neko]
2+
command=/usr/bin/neko serve --bind 0.0.0.0:8000 --config /etc/neko/neko.yaml --static /var/www
3+
autostart=true
4+
autorestart=true
5+
stdout_logfile=/var/log/supervisor/neko.log
6+
stderr_logfile=/var/log/supervisor/neko.error.log
7+
environment=DISPLAY=":1.0",HOME="/root"
8+
priority=20

0 commit comments

Comments
 (0)