Skip to content

Commit 501fbb5

Browse files
committed
Refactoring
1 parent d0b464c commit 501fbb5

20 files changed

+94
-187
lines changed

CLAUDE.md

Lines changed: 45 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,28 @@ supervisord
5353
web-agent/
5454
├── browser-operator-core/ # Submodule: DevTools frontend source
5555
├── kernel-images/ # Submodule: Base browser environment
56+
├── deployment/ # Deployment configurations
57+
│ ├── cloudrun/ # Google Cloud Run deployment
58+
│ │ ├── deploy.sh # Cloud deployment script
59+
│ │ ├── cloudbuild.yaml # CI/CD pipeline config
60+
│ │ ├── service.yaml # Cloud Run service definition
61+
│ │ ├── service-secrets.yaml # Service with Secret Manager
62+
│ │ ├── cloudrun-wrapper.sh # Cloud Run entrypoint
63+
│ │ ├── cloudrun-kernel-wrapper.sh # Alternative wrapper
64+
│ │ ├── supervisord-cloudrun.conf # Supervisor for Cloud Run
65+
│ │ └── nginx.conf # Reverse proxy config
66+
│ └── local/ # Local deployment
67+
│ └── run-local.sh # Interactive Docker run script
68+
├── nginx/ # Nginx configurations
69+
│ └── nginx-devtools.conf # DevTools nginx config
70+
├── scripts/ # Utility scripts
71+
│ ├── init-container.sh # Auto-cleanup of lock files
72+
│ └── test-eval-server.sh # Eval server build test
73+
├── supervisor/services/ # Service configs (override defaults)
74+
│ ├── chromium.conf # Auto-open DevTools
75+
│ ├── eval-server.conf # Eval server with CDP_PORT=9223
76+
│ ├── neko.conf
77+
│ └── nginx-devtools.conf
5678
├── eval-server/
5779
│ └── nodejs/ # Eval server source (use this, NOT submodule)
5880
│ ├── src/
@@ -65,20 +87,13 @@ web-agent/
6587
│ ├── run.py # Python evaluation runner
6688
│ ├── lib/judge.py # LLMJudge, VisionJudge, SimpleJudge
6789
│ └── data/ # Evaluation YAML files
68-
├── scripts/
69-
│ ├── init-container.sh # Auto-cleanup of lock files
70-
│ └── cleanup-chromium-locks.sh
71-
├── supervisor/services/ # Service configs (override defaults)
72-
│ ├── chromium.conf # Auto-open DevTools
73-
│ ├── eval-server.conf # Eval server with CDP_PORT=9223
74-
│ ├── neko.conf
75-
│ └── nginx-devtools.conf
76-
├── Dockerfile.local # Main Docker build
90+
├── Dockerfile.local # Main Docker build (local dev)
7791
├── Dockerfile.devtools # DevTools frontend build
92+
├── Dockerfile.cloudrun # Cloud Run build
7893
├── docker-compose.yml # Local deployment config
79-
├── run-local.sh # Interactive mode startup
8094
├── Makefile # Build/deployment commands
81-
└── README.md
95+
├── CLAUDE.md # This file
96+
└── README.md # User documentation
8297
```
8398

8499
## Key Files and What They Do
@@ -144,7 +159,7 @@ Key targets:
144159
- `make stop` - Stop all containers
145160
- `make clean` - Clean up everything
146161

147-
### run-local.sh
162+
### deployment/local/run-local.sh
148163
Interactive Docker run script that:
149164
- Sources kernel-images common build variables
150165
- Creates local recordings directory
@@ -161,6 +176,24 @@ Interactive Docker run script that:
161176
- More flexible for custom configurations via environment variables
162177
- Better for seeing startup issues and debugging
163178

179+
### deployment/cloudrun/
180+
Contains all Google Cloud Run deployment files:
181+
- `deploy.sh` - Automated deployment script with Twilio TURN setup
182+
- `cloudbuild.yaml` - CI/CD pipeline for Cloud Build
183+
- `service.yaml` / `service-secrets.yaml` - Cloud Run service definitions
184+
- `cloudrun-wrapper.sh` - Cloud Run container entrypoint
185+
- `supervisord-cloudrun.conf` - Supervisor configuration for Cloud Run
186+
- `nginx.conf` - Reverse proxy for Cloud Run port requirements
187+
188+
### nginx/
189+
Nginx configuration files:
190+
- `nginx-devtools.conf` - DevTools UI server config (used by Dockerfile.local)
191+
192+
### scripts/
193+
Utility scripts:
194+
- `init-container.sh` - Automatic lock file cleanup on container start
195+
- `test-eval-server.sh` - Test eval-server Docker build stage
196+
164197
## Common Issues and Solutions
165198

166199
### 1. Chromium Profile Lock Errors

Dockerfile.cloudrun

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ COPY kernel-images/images/chromium-headful/image-chromium/ /
259259
COPY kernel-images/images/chromium-headful/start-chromium.sh /images/chromium-headful/start-chromium.sh
260260
RUN chmod +x /images/chromium-headful/start-chromium.sh
261261
COPY kernel-images/images/chromium-headful/supervisord.conf /etc/supervisor/supervisord.conf
262-
COPY supervisord-cloudrun.conf /etc/supervisor/supervisord-cloudrun.conf
262+
COPY deployment/cloudrun/supervisord-cloudrun.conf /etc/supervisor/supervisord-cloudrun.conf
263263
COPY kernel-images/images/chromium-headful/supervisor/services/ /etc/supervisor/conf.d/services/
264264

265265
# Copy the kernel-images API binary
@@ -291,7 +291,7 @@ RUN chown -R kernel:kernel /opt/eval-server
291291

292292
# Cloud Run specific: wrapper scripts (nginx config is inline)
293293
# DO NOT copy nginx.conf to avoid auto-start conflicts
294-
COPY cloudrun-wrapper.sh /cloudrun-wrapper.sh
294+
COPY deployment/cloudrun/cloudrun-wrapper.sh /cloudrun-wrapper.sh
295295
COPY twilio/twilio-credential-updater.sh /twilio-credential-updater.sh
296296
RUN chmod +x /cloudrun-wrapper.sh /twilio-credential-updater.sh
297297

Dockerfile.kernel-cloud

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ RUN mkdir -p /chromium && \
208208
chown -R kernel:kernel /chromium
209209

210210
# Cloud Run wrapper that starts kernel-images services + nginx proxy
211-
COPY cloudrun-kernel-wrapper.sh /cloudrun-kernel-wrapper.sh
211+
COPY deployment/cloudrun/cloudrun-kernel-wrapper.sh /cloudrun-kernel-wrapper.sh
212212
RUN chmod +x /cloudrun-kernel-wrapper.sh
213213

214214
# Cloud Run requires non-root execution

Dockerfile.local

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ COPY --from=server-builder /out/kernel-images-api /usr/local/bin/kernel-images-a
221221
COPY --from=devtools-source /usr/share/nginx/html /usr/share/nginx/devtools
222222

223223
# Create DevTools nginx configuration
224-
COPY nginx-devtools.conf /etc/nginx/sites-available/devtools
224+
COPY nginx/nginx-devtools.conf /etc/nginx/sites-available/devtools
225225
RUN ln -s /etc/nginx/sites-available/devtools /etc/nginx/sites-enabled/devtools && \
226226
rm /etc/nginx/sites-enabled/default
227227

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ rebuild: init ## Force complete rebuild (including DevTools)
7878
run: ## Run extended container with DevTools (interactive)
7979
@echo "🚀 Starting extended kernel-browser with DevTools..."
8080
@if [ -n "$(URLS)" ]; then echo "📄 Opening URLs: $(URLS)"; fi
81-
@./run-local.sh
81+
@./deployment/local/run-local.sh
8282

8383
compose-up: build ## Start with docker-compose (background)
8484
@echo "🚀 Starting with docker-compose..."

Readme.md

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -318,10 +318,10 @@ gcloud auth application-default login
318318

319319
```bash
320320
# Automated deployment (recommended)
321-
./deploy.sh
321+
./deployment/cloudrun/deploy.sh
322322

323323
# Or with custom settings
324-
./deploy.sh --project your-project-id --region us-central1
324+
./deployment/cloudrun/deploy.sh --project your-project-id --region us-central1
325325
```
326326

327327
### Access Cloud Run Service
@@ -435,6 +435,24 @@ For production WebRTC, configure a TURN server:
435435
web-agent/
436436
├── browser-operator-core/ # Submodule: DevTools frontend source
437437
├── kernel-images/ # Submodule: Base browser environment
438+
├── deployment/ # Deployment configurations
439+
│ ├── cloudrun/ # Google Cloud Run deployment
440+
│ │ ├── deploy.sh # Cloud deployment script
441+
│ │ ├── cloudbuild.yaml # CI/CD pipeline config
442+
│ │ ├── service.yaml # Cloud Run service definition
443+
│ │ ├── service-secrets.yaml # Service with Secret Manager
444+
│ │ ├── cloudrun-wrapper.sh # Cloud Run entrypoint
445+
│ │ ├── cloudrun-kernel-wrapper.sh # Alternative wrapper
446+
│ │ ├── supervisord-cloudrun.conf # Supervisor for Cloud Run
447+
│ │ └── nginx.conf # Reverse proxy config
448+
│ └── local/ # Local deployment
449+
│ └── run-local.sh # Interactive Docker run script
450+
├── nginx/ # Nginx configurations
451+
│ └── nginx-devtools.conf # DevTools nginx config
452+
├── scripts/ # Utility scripts
453+
│ ├── init-container.sh # Auto-cleanup of lock files
454+
│ └── test-eval-server.sh # Eval server build test
455+
├── supervisor/services/ # Service configs (overrides)
438456
├── eval-server/
439457
│ └── nodejs/ # Eval server (use this, NOT submodule)
440458
│ ├── src/ # API server, evaluation server, lib
@@ -444,19 +462,11 @@ web-agent/
444462
│ ├── run.py # Python evaluation runner
445463
│ ├── lib/judge.py # Judge implementations
446464
│ └── data/ # Evaluation YAML files
447-
├── scripts/
448-
│ └── init-container.sh # Auto-cleanup of lock files
449-
├── supervisor/services/ # Service configs (overrides)
450-
├── Dockerfile.local # Main Docker build
465+
├── Dockerfile.local # Main Docker build (local dev)
451466
├── Dockerfile.devtools # DevTools frontend build
452-
├── docker-compose.yml # Local deployment
453-
├── run-local.sh # Interactive mode
454-
├── Makefile # Build commands
455467
├── Dockerfile.cloudrun # Cloud Run build
456-
├── nginx.conf # Reverse proxy config
457-
├── service.yaml # Cloud Run service config
458-
├── cloudbuild.yaml # CI/CD pipeline
459-
├── deploy.sh # Cloud deployment script
468+
├── docker-compose.yml # Local deployment config
469+
├── Makefile # Build commands
460470
├── CLAUDE.md # Technical documentation
461471
└── README.md # This file
462472
```
@@ -541,13 +551,13 @@ The `cloudbuild.yaml` provides:
541551

542552
```bash
543553
# Normal build (with cache) - recommended for development
544-
gcloud builds submit --config cloudbuild.yaml
554+
gcloud builds submit --config deployment/cloudrun/cloudbuild.yaml
545555

546556
# Force rebuild without cache - use when dependencies change
547-
gcloud builds submit --config cloudbuild.yaml --substitutions=_NO_CACHE=true
557+
gcloud builds submit --config deployment/cloudrun/cloudbuild.yaml --substitutions=_NO_CACHE=true
548558

549559
# Automated deployment with Twilio TURN server setup
550-
./deploy.sh
560+
./deployment/cloudrun/deploy.sh
551561
```
552562

553563
### Cache Control
File renamed without changes.
File renamed without changes.
File renamed without changes.

deploy.sh renamed to deployment/cloudrun/deploy.sh

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,16 @@
33
set -euo pipefail
44

55
# Kernel-Browser Cloud Run Deployment Script
6+
# NOTE: This script should be run from the project root directory
67
echo "🚀 Starting kernel-browser deployment to Google Cloud Run..."
78

9+
# Verify we're in the project root
10+
if [ ! -f "docker-compose.yml" ]; then
11+
echo "❌ Error: This script must be run from the project root directory"
12+
echo " Expected to find docker-compose.yml in current directory"
13+
exit 1
14+
fi
15+
816
# Configuration
917
PROJECT_ID="${PROJECT_ID:-}"
1018
REGION="${REGION:-us-central1}"
@@ -298,7 +306,7 @@ deploy_with_cloudbuild() {
298306

299307
# Submit build
300308
gcloud builds submit \
301-
--config=cloudbuild.yaml \
309+
--config=deployment/cloudrun/cloudbuild.yaml \
302310
--project="$PROJECT_ID" \
303311
--timeout="2h" \
304312
--machine-type="e2-highcpu-32"
@@ -321,11 +329,11 @@ deploy_local() {
321329
info "Deploying to Cloud Run..."
322330

323331
# Choose appropriate service.yaml based on secrets availability
324-
local service_file="service.yaml"
332+
local service_file="deployment/cloudrun/service.yaml"
325333
if [ "${USE_SECRETS:-false}" = "true" ]; then
326334
if gcloud secrets describe twilio-account-sid --project="$PROJECT_ID" &>/dev/null && \
327335
gcloud secrets describe twilio-auth-token --project="$PROJECT_ID" &>/dev/null; then
328-
service_file="service-secrets.yaml"
336+
service_file="deployment/cloudrun/service-secrets.yaml"
329337
info "Using service-secrets.yaml with Secret Manager references"
330338
else
331339
warning "Secrets not found, falling back to standard service.yaml"

0 commit comments

Comments
 (0)