Skip to content

Commit edbf470

Browse files
committed
Make dev build
1 parent 9a07b1f commit edbf470

File tree

9 files changed

+783
-98
lines changed

9 files changed

+783
-98
lines changed

β€Ž.gitignoreβ€Ž

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,10 @@ service-account-key.json
5454
*.backup
5555

5656
# Chromium persistent data
57-
chromium-data/
57+
chromium-data/
58+
59+
# Browser Operator DevTools build artifacts
60+
browser-operator-core/devtools-frontend/
61+
browser-operator-core/depot_tools/
62+
browser-operator-core/.devtools-built
63+
browser-operator-core/.devtools-base-built

β€Ž.gitmodulesβ€Ž

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
[submodule "kernel-images"]
22
path = kernel-images
33
url = https://github.com/onkernel/kernel-images.git
4+
5+
[submodule "browser-operator-core"]
6+
path = browser-operator-core
7+
url = git@github.com:BrowserOperator/browser-operator-core.git
8+
shallow = true

β€ŽDockerfile.devtoolsβ€Ž

Lines changed: 57 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1-
# DevTools Frontend build stage using browser-operator-core
2-
FROM --platform=linux/amd64 ubuntu:22.04 AS devtools-builder
1+
# Development-optimized Dockerfile for Browser Operator DevTools
2+
# This Dockerfile is designed for fast iterative builds during local development
3+
# It caches expensive operations (fetch, sync) and allows quick rebuilds when code changes
34

4-
# Install required packages for DevTools frontend build
5+
# ==============================================================================
6+
# Stage 1: DevTools Base (cached, rarely rebuilt)
7+
# ==============================================================================
8+
FROM --platform=linux/amd64 ubuntu:22.04 AS devtools-base
9+
10+
# Install required packages
511
RUN apt-get update && apt-get install -y \
612
curl \
713
git \
@@ -22,42 +28,76 @@ RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && \
2228

2329
WORKDIR /workspace
2430

25-
# Clone depot_tools
31+
# Clone depot_tools (cached)
2632
RUN git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
2733
ENV PATH="/workspace/depot_tools:${PATH}"
2834
ENV DEPOT_TOOLS_UPDATE=0
2935

30-
# Follow README instructions exactly - fetching code
36+
# Fetch devtools-frontend (expensive operation, cached)
3137
RUN mkdir devtools
3238
WORKDIR /workspace/devtools
3339
RUN fetch devtools-frontend
3440

3541
# Build steps
3642
WORKDIR /workspace/devtools/devtools-frontend
3743

44+
# Sync dependencies (cached)
3845
RUN gclient sync
3946
RUN /workspace/depot_tools/ensure_bootstrap
4047

41-
# Build standard DevTools first
48+
# Build standard DevTools first (cached)
4249
RUN npm run build
4350

44-
# Add Browser Operator fork and switch to it
51+
# Create marker file to indicate base is built
52+
RUN touch /workspace/.devtools-base-built
53+
54+
# ==============================================================================
55+
# Stage 2: Apply Browser Operator Changes (fast, iterative)
56+
# ==============================================================================
57+
FROM devtools-base AS devtools-local
58+
59+
WORKDIR /workspace/devtools/devtools-frontend
60+
61+
# Add Browser Operator fork
4562
RUN git remote add upstream https://github.com/BrowserOperator/browser-operator-core.git
4663
RUN git fetch upstream
4764
RUN git checkout upstream/main
4865

49-
# Build Browser Operator version
66+
# This is where local changes would be copied in development mode
67+
# When building from submodule, copy local changes here:
68+
# COPY will be added by build script if browser-operator-core/ exists locally
69+
70+
# Force automated mode
71+
RUN sed -i 's/AUTOMATED_MODE: false/AUTOMATED_MODE: true/' front_end/panels/ai_chat/core/BuildConfig.ts || true
72+
73+
# Build Browser Operator version with current changes
5074
RUN npm run build
5175

52-
# Production stage for DevTools frontend
53-
FROM nginx:alpine AS devtools-frontend
54-
WORKDIR /usr/share/nginx/html
76+
# Create marker file
77+
RUN touch /workspace/.devtools-built
78+
79+
# ==============================================================================
80+
# Stage 3: Nginx Server (optional, for standalone testing)
81+
# ==============================================================================
82+
FROM nginx:alpine AS devtools-server
83+
84+
# Copy the built DevTools frontend
85+
COPY --from=devtools-local /workspace/devtools/devtools-frontend/out/Default/gen/front_end /usr/share/nginx/html
5586

56-
# Copy the built DevTools frontend from builder
57-
COPY --from=devtools-builder /workspace/devtools/devtools-frontend/out/Default/gen/front_end .
87+
# Create simple nginx config
88+
RUN echo 'server { \
89+
listen 8001; \
90+
root /usr/share/nginx/html; \
91+
location / { \
92+
try_files $uri $uri/ /index.html; \
93+
} \
94+
location /health { \
95+
return 200 "{\"status\":\"healthy\"}"; \
96+
add_header Content-Type application/json; \
97+
} \
98+
}' > /etc/nginx/conf.d/default.conf
5899

59-
# Copy nginx config from browser-operator-core
60-
COPY browser-operator-core/docker/nginx.conf /etc/nginx/conf.d/default.conf
100+
EXPOSE 8001
61101

62-
# Create health check endpoint
63-
RUN echo '{"status": "healthy", "service": "browser-operator-devtools"}' > health.json
102+
# Create health check file
103+
RUN echo '{"status": "healthy", "service": "browser-operator-devtools"}' > /usr/share/nginx/html/health.json

β€ŽDockerfile.localβ€Ž

Lines changed: 11 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,13 @@
11
# Extended Dockerfile combining kernel-images with DevTools frontend
22
# This extends the kernel-images base with Browser Operator DevTools static files
3+
#
4+
# NOTE: DevTools are built separately using Dockerfile.devtools
5+
# Run 'make build-devtools' first to build the DevTools image
36

4-
# DevTools Frontend build stage using browser-operator-core
5-
FROM --platform=linux/amd64 ubuntu:22.04 AS devtools-builder
6-
7-
# Install required packages
8-
RUN apt-get update && apt-get install -y \
9-
curl \
10-
git \
11-
python3 \
12-
python3-pip \
13-
python-is-python3 \
14-
wget \
15-
unzip \
16-
sudo \
17-
ca-certificates \
18-
build-essential \
19-
&& rm -rf /var/lib/apt/lists/*
20-
21-
# Install Node.js 18.x
22-
RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && \
23-
apt-get install -y nodejs && \
24-
rm -rf /var/lib/apt/lists/*
25-
26-
WORKDIR /workspace
27-
28-
# Clone depot_tools
29-
RUN git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
30-
ENV PATH="/workspace/depot_tools:${PATH}"
31-
ENV DEPOT_TOOLS_UPDATE=0
32-
33-
# Follow README instructions exactly:
34-
# fetching code
35-
RUN mkdir devtools
36-
WORKDIR /workspace/devtools
37-
RUN fetch devtools-frontend
38-
39-
# Build steps
40-
WORKDIR /workspace/devtools/devtools-frontend
41-
42-
RUN gclient sync
43-
RUN /workspace/depot_tools/ensure_bootstrap
44-
45-
# Build standard DevTools first
46-
RUN npm run build
47-
48-
# Add Browser Operator fork and switch to it
49-
RUN git remote add upstream https://github.com/BrowserOperator/browser-operator-core.git
50-
RUN git fetch upstream
51-
RUN git checkout upstream/main
52-
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
64-
RUN npm run build
7+
# ============================================================================
8+
# DevTools stage - Copy from pre-built devtools image
9+
# ============================================================================
10+
FROM browser-operator-devtools:latest AS devtools-source
6511

6612
# ============================================================================
6713
# Eval Server build stage
@@ -70,8 +16,8 @@ FROM --platform=linux/arm64 node:18-alpine AS eval-server-builder
7016

7117
WORKDIR /workspace
7218

73-
# Copy local eval server
74-
COPY eval-server/nodejs /workspace/eval-server
19+
# Copy eval server from browser-operator-core submodule
20+
COPY browser-operator-core/eval-server/nodejs /workspace/eval-server
7521

7622
WORKDIR /workspace/eval-server
7723

@@ -271,8 +217,8 @@ COPY --from=server-builder /out/kernel-images-api /usr/local/bin/kernel-images-a
271217
# DevTools Integration
272218
# ============================================================================
273219

274-
# Copy DevTools static files from builder
275-
COPY --from=devtools-builder /workspace/devtools/devtools-frontend/out/Default/gen/front_end /usr/share/nginx/devtools
220+
# Copy DevTools static files from pre-built devtools image
221+
COPY --from=devtools-source /usr/share/nginx/html /usr/share/nginx/devtools
276222

277223
# Create DevTools nginx configuration
278224
COPY nginx-devtools.conf /etc/nginx/sites-available/devtools

β€ŽMakefileβ€Ž

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,38 @@ help: ## Show this help message
1717
@echo " - Disable persistence: CHROMIUM_DATA_HOST=\"\" make run"
1818

1919
init: ## Initialize submodules (run this first)
20-
git submodule update --init --recursive
20+
@echo "πŸ“¦ Initializing submodules..."
21+
git submodule update --init --depth 1 kernel-images
22+
git submodule update --init --depth 1 browser-operator-core
2123
@echo "βœ… Submodules initialized"
2224

23-
build: init ## Build extended image with DevTools frontend
25+
init-devtools: ## Initialize browser-operator-core submodule only
26+
@echo "πŸ“¦ Initializing browser-operator-core submodule..."
27+
git submodule update --init --depth 1 browser-operator-core
28+
@echo "βœ… browser-operator-core submodule initialized"
29+
30+
build-devtools-base: init-devtools ## Build DevTools base image (slow, rarely needed)
31+
@echo "πŸ”¨ Building DevTools base layer (this takes ~30 minutes)..."
32+
docker build -f Dockerfile.devtools --target devtools-base -t browser-operator-devtools:base .
33+
@echo "βœ… DevTools base built and cached"
34+
35+
build-devtools: init-devtools ## Build DevTools image (smart: uses cache)
36+
@if docker images | grep -q "browser-operator-devtools.*base"; then \
37+
echo "βœ… Using cached DevTools base"; \
38+
else \
39+
echo "πŸ“¦ DevTools base not found, building from scratch..."; \
40+
$(MAKE) --no-print-directory build-devtools-base; \
41+
fi
42+
@echo "πŸ”¨ Building Browser Operator DevTools..."
43+
docker build -f Dockerfile.devtools --target devtools-server -t browser-operator-devtools:latest .
44+
@echo "βœ… DevTools built: browser-operator-devtools:latest"
45+
46+
rebuild-devtools: ## Force rebuild DevTools (use after code changes)
47+
@echo "πŸ”„ Force rebuilding DevTools..."
48+
docker build -f Dockerfile.devtools --no-cache --target devtools-server -t browser-operator-devtools:latest .
49+
@echo "βœ… DevTools rebuilt"
50+
51+
build: init build-devtools ## Build extended image with DevTools frontend
2452
@echo "πŸ”¨ Building extended kernel-browser with DevTools frontend..."
2553
docker build -f Dockerfile.local -t kernel-browser:extended .
2654
@echo "βœ… Extended build complete"
@@ -112,6 +140,12 @@ clean: stop ## Clean up everything
112140
rm -rf kernel-images/images/chromium-headful/.tmp 2>/dev/null || true
113141
@echo "βœ… Cleanup complete"
114142

143+
clean-devtools: ## Clean DevTools images and cache
144+
@echo "🧹 Cleaning DevTools images..."
145+
docker rmi browser-operator-devtools:latest 2>/dev/null || true
146+
docker rmi browser-operator-devtools:base 2>/dev/null || true
147+
@echo "βœ… DevTools images removed"
148+
115149
# Alternative commands for different approaches
116150
native-build: init ## Build using kernel-images native script directly
117151
cd kernel-images/images/chromium-headful && \

β€Žbrowser-operator-coreβ€Ž

Submodule browser-operator-core added at cfd482d

β€Žbuild-local.shβ€Ž

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,24 @@ echo "πŸ”¨ Building extended kernel-browser with DevTools frontend..."
99
SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
1010
cd "$SCRIPT_DIR"
1111

12-
# Fix orphaned browser-operator-core submodule if it exists
13-
if [ -d "browser-operator-core" ] && ! grep -q "browser-operator-core" .gitmodules 2>/dev/null; then
14-
echo "πŸ”§ Fixing orphaned browser-operator-core submodule..."
15-
git rm -f browser-operator-core 2>/dev/null || true
16-
rm -rf .git/modules/browser-operator-core 2>/dev/null || true
17-
echo "βœ… Removed orphaned submodule"
12+
# Initialize submodules if needed
13+
if [ ! -d "kernel-images/.git" ]; then
14+
echo "πŸ“¦ Initializing kernel-images submodule..."
15+
git submodule update --init --depth 1 kernel-images
1816
fi
1917

20-
# Check if kernel-images submodule exists and is initialized
21-
if [ ! -d "kernel-images" ] || [ ! -f "kernel-images/images/chromium-headful/build-docker.sh" ]; then
22-
echo "πŸ“¦ Initializing kernel-images submodule..."
23-
git submodule update --init --recursive
18+
if [ ! -d "browser-operator-core/.git" ]; then
19+
echo "πŸ“¦ Initializing browser-operator-core submodule..."
20+
git submodule update --init --depth 1 browser-operator-core
2421
fi
2522

26-
if [ ! -f "kernel-images/images/chromium-headful/build-docker.sh" ]; then
27-
echo "❌ Error: kernel-images submodule appears empty after initialization"
28-
exit 1
23+
# Check if DevTools image exists
24+
if ! docker images | grep -q "browser-operator-devtools.*latest"; then
25+
echo "πŸ“¦ DevTools image not found, building it first..."
26+
echo " This is a one-time operation and will take ~30 minutes..."
27+
make build-devtools
28+
else
29+
echo "βœ… Using existing DevTools image"
2930
fi
3031

3132
echo "πŸš€ Starting extended build with Docker..."

0 commit comments

Comments
Β (0)