11# Multi-stage build for Chrome DevTools Frontend
2- # Stage 1: Builder - Use x86-64 for build compatibility
32FROM --platform=linux/amd64 ubuntu:22.04 AS builder
43
5- # Install required packages for the build
4+ # Install required packages
65RUN apt-get update && apt-get install -y \
76 curl \
87 git \
@@ -11,74 +10,53 @@ RUN apt-get update && apt-get install -y \
1110 python-is-python3 \
1211 wget \
1312 unzip \
14- lsb-release \
1513 sudo \
1614 ca-certificates \
17- gnupg \
15+ build-essential \
1816 && rm -rf /var/lib/apt/lists/*
1917
20- # Install Node.js 18.x (LTS)
18+ # Install Node.js 18.x
2119RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && \
2220 apt-get install -y nodejs && \
2321 rm -rf /var/lib/apt/lists/*
2422
25- # Set up working directory
2623WORKDIR /workspace
2724
28- # Copy the entire repository
29- COPY . .
30-
31- # Clone depot_tools if not exists and add to PATH
32- RUN if [ ! -d "third_party/depot_tools" ]; then \
33- git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git third_party/depot_tools; \
34- fi
35-
36- # Set PATH to include depot_tools
37- ENV PATH="/workspace/third_party/depot_tools:${PATH}"
38-
39- # Set environment variables to bypass CIPD issues
40- ENV VPYTHON_BYPASS="manually managed python not supported by chrome operations"
25+ # Clone depot_tools
26+ RUN git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
27+ ENV PATH="/workspace/depot_tools:${PATH}"
4128ENV DEPOT_TOOLS_UPDATE=0
4229
43- # Download Node.js binary for the expected path (x86-64)
44- RUN mkdir -p third_party/node/linux && \
45- cd third_party/node/linux && \
46- wget -q https://nodejs.org/dist/v18.20.0/node-v18.20.0-linux-x64.tar.xz && \
47- tar -xf node-v18.20.0-linux-x64.tar.xz && \
48- mv node-v18.20.0-linux-x64 node-linux-x64 && \
49- rm -rf node-v18.20.0-linux-x64.tar.xz
30+ # Follow README instructions exactly:
31+ # fetching code
32+ RUN mkdir devtools
33+ WORKDIR /workspace/devtools
34+ RUN fetch devtools-frontend
5035
51- # Download correct ninja binary for x86-64
52- RUN rm -rf third_party/ninja && \
53- mkdir -p third_party/ninja && \
54- wget -O /tmp/ninja.zip https://github.com/ninja-build/ninja/releases/download/v1.11.1/ninja-linux.zip && \
55- unzip -o /tmp/ninja.zip -d third_party/ninja/ && \
56- chmod +x third_party/ninja/ninja && \
57- rm /tmp/ninja.zip
36+ # Build steps
37+ WORKDIR /workspace/devtools/devtools-frontend
5838
59- # Create a simple python3 wrapper for vpython3
60- RUN echo '#!/bin/bash\n exec python3 "$@"' > /usr/local/bin/vpython3 && \
61- chmod +x /usr/local/bin/vpython3
39+ RUN gclient sync
40+ RUN /workspace/depot_tools/ensure_bootstrap
6241
63- # Run npm install and build
64- RUN npm install && \
65- npm run build
42+ # Build standard DevTools first
43+ RUN npm run build
6644
67- # Stage 2: Production
68- FROM nginx:alpine
45+ # Add Browser Operator fork and switch to it
46+ RUN git remote add upstream https://github.com/BrowserOperator/browser-operator-core.git
47+ RUN git fetch upstream
48+ RUN git checkout upstream/main
6949
70- # Copy only the built frontend files from builder stage
71- COPY --from=builder /workspace/out/Default/gen/front_end /usr/share/nginx/html
50+ # Build Browser Operator version
51+ RUN npm run build
7252
73- # Copy nginx configuration
74- COPY docker/nginx.conf /etc/ nginx/conf.d/default.conf
53+ # Production stage
54+ FROM --platform=linux/amd64 nginx:alpine
7555
76- # Expose port 8000 to match the original Python server port
77- EXPOSE 8000
56+ # Copy the built DevTools frontend
57+ COPY --from=builder /workspace/devtools/devtools-frontend/out/Default/gen/front_end /usr/share/nginx/html
7858
79- # Health check
80- HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
81- CMD wget --no-verbose --tries=1 --spider http://localhost:8000/ || exit 1
59+ # Copy nginx config
60+ COPY docker/nginx.conf /etc/nginx/conf.d/default.conf
8261
83- # Start nginx
84- CMD ["nginx" , "-g" , "daemon off;" ]
62+ EXPOSE 8000
0 commit comments