Skip to content

Commit 1452d74

Browse files
authored
Fixed docker build (#40)
## Pull Request Overview This PR adds Docker configuration and documentation to enable containerized deployment of the DevTools frontend. The changes focus on creating a reproducible build environment that follows the exact setup process outlined in the original README. - Added multi-stage Dockerfile that properly clones depot_tools, fetches devtools-frontend, and switches to Browser Operator fork - Updated AI Chat panel README with Docker deployment instructions - Configured nginx to serve the built frontend on port 8000
1 parent 6d4ec47 commit 1452d74

File tree

2 files changed

+43
-53
lines changed

2 files changed

+43
-53
lines changed

docker/Dockerfile

Lines changed: 30 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
# Multi-stage build for Chrome DevTools Frontend
2-
# Stage 1: Builder - Use x86-64 for build compatibility
32
FROM --platform=linux/amd64 ubuntu:22.04 AS builder
43

5-
# Install required packages for the build
4+
# Install required packages
65
RUN 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
2119
RUN 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
2623
WORKDIR /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}"
4128
ENV 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\nexec 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

front_end/panels/ai_chat/Readme.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@
22

33
This panel is a Multi-Agent Framework that allows a user to connect an existing LLM with the chromium browser.
44

5+
### Docker
6+
```sh
7+
# assuming you are running from the root "browser-operator-core" directory
8+
docker build -f docker/Dockerfile -t devtools-frontend .
9+
docker run -d -p 8000:8000 --name devtools-frontend devtools-frontend
10+
<path-to-devtools-frontend>/third_party/chrome/chrome-<platform>/chrome --disable-infobars --custom-devtools-frontend=http://localhost:8000/
11+
12+
# MacOS Example
13+
/Applications/Google\ Chrome\ Canary.app/Contents/MacOS/Google\ Chrome\ Canary --custom-devtools-frontend=http://localhost:8000/
14+
```
15+
16+
517
### Steps to run project
618

719
1. Setup the depot_tools to fetch the chromium dev tools using the instructions provided [here](https://www.chromium.org/developers/how-tos/get-the-code/)
@@ -25,7 +37,7 @@ npm run build
2537

2638
3. Update the code to this fork implementation
2739
```sh
28-
git remote add upstream git@github.com:tysonthomas9/browser-operator-devtools-frontend.git
40+
git remote add upstream https://github.com/BrowserOperator/browser-operator-core.git
2941
git fetch upstream
3042
git checkout upstream/main
3143
```

0 commit comments

Comments
 (0)