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
511RUN 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
2329WORKDIR /workspace
2430
25- # Clone depot_tools
31+ # Clone depot_tools (cached)
2632RUN git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
2733ENV PATH="/workspace/depot_tools:${PATH}"
2834ENV DEPOT_TOOLS_UPDATE=0
2935
30- # Follow README instructions exactly - fetching code
36+ # Fetch devtools-frontend (expensive operation, cached)
3137RUN mkdir devtools
3238WORKDIR /workspace/devtools
3339RUN fetch devtools-frontend
3440
3541# Build steps
3642WORKDIR /workspace/devtools/devtools-frontend
3743
44+ # Sync dependencies (cached)
3845RUN gclient sync
3946RUN /workspace/depot_tools/ensure_bootstrap
4047
41- # Build standard DevTools first
48+ # Build standard DevTools first (cached)
4249RUN 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
4562RUN git remote add upstream https://github.com/BrowserOperator/browser-operator-core.git
4663RUN git fetch upstream
4764RUN 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
5074RUN 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
0 commit comments