Skip to content

Commit a047732

Browse files
committed
merge dockerfile
1 parent 81c0f47 commit a047732

File tree

13 files changed

+630
-642
lines changed

13 files changed

+630
-642
lines changed

.env.example

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@ ANONYMIZED_TELEMETRY=false
4040
# LogLevel: Set to debug to enable verbose logging, set to result to get results only. Available: result | debug | info
4141
BROWSER_USE_LOGGING_LEVEL=info
4242

43-
# Chrome settings
44-
CHROME_PATH=
45-
CHROME_USER_DATA=
46-
CHROME_DEBUGGING_PORT=9222
47-
CHROME_DEBUGGING_HOST=localhost
43+
# Browser settings
44+
BROWSER_PATH=
45+
BROWSER_USER_DATA=
46+
BROWSER_DEBUGGING_PORT=9222
47+
BROWSER_DEBUGGING_HOST=localhost
4848
# Set to true to keep browser open between AI tasks
49-
CHROME_PERSISTENT_SESSION=false
50-
CHROME_CDP=
49+
KEEP_BROWSER_OPEN=true
50+
BROWSER_CDP=
5151
# Display settings
5252
# Format: WIDTHxHEIGHTxDEPTH
5353
RESOLUTION=1920x1080x24

Dockerfile

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
FROM python:3.11-slim
22

3+
# Set platform for multi-arch builds (Docker Buildx will set this)
4+
ARG TARGETPLATFORM
5+
36
# Install system dependencies
47
RUN apt-get update && apt-get install -y \
58
wget \
@@ -28,7 +31,6 @@ RUN apt-get update && apt-get install -y \
2831
fonts-liberation \
2932
dbus \
3033
xauth \
31-
xvfb \
3234
x11vnc \
3335
tigervnc-tools \
3436
supervisor \
@@ -47,40 +49,52 @@ RUN git clone https://github.com/novnc/noVNC.git /opt/novnc \
4749
&& git clone https://github.com/novnc/websockify /opt/novnc/utils/websockify \
4850
&& ln -s /opt/novnc/vnc.html /opt/novnc/index.html
4951

50-
# Set platform for ARM64 compatibility
51-
ARG TARGETPLATFORM=linux/amd64
52-
5352
# Set up working directory
5453
WORKDIR /app
5554

5655
# Copy requirements and install Python dependencies
5756
COPY requirements.txt .
58-
RUN pip install --no-cache-dir -r requirements.txt
57+
# Ensure 'patchright' is in your requirements.txt or install it directly
58+
# RUN pip install --no-cache-dir -r requirements.txt patchright # If not in requirements
59+
RUN pip install --no-cache-dir -r requirements.txt # Assuming patchright is in requirements.txt
60+
RUN pip install --no-cache-dir patchright # Or install it explicitly
61+
62+
# Install Patchright browsers and dependencies
63+
# Patchright documentation suggests PLAYWRIGHT_BROWSERS_PATH is still relevant
64+
# or that Patchright installs to a similar default location that Playwright would.
65+
# Let's assume Patchright respects PLAYWRIGHT_BROWSERS_PATH or its default install location is findable.
66+
ENV PLAYWRIGHT_BROWSERS_PATH=/ms-browsers
67+
RUN mkdir -p $PLAYWRIGHT_BROWSERS_PATH
68+
69+
# Install recommended: Google Chrome (instead of just Chromium for better undetectability)
70+
# The 'patchright install chrome' command might download and place it.
71+
# The '--with-deps' equivalent for patchright install is to run 'patchright install-deps chrome' after.
72+
RUN patchright install chrome
73+
RUN patchright install-deps chrome
5974

60-
# Install Playwright and browsers with system dependencies
61-
ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright
62-
RUN playwright install --with-deps chromium
63-
RUN playwright install-deps
75+
# Alternative: Install Chromium if Google Chrome is problematic in certain environments
76+
RUN patchright install chromium
77+
RUN patchright install-deps chromium
6478

6579
# Copy the application code
6680
COPY . .
6781

68-
# Set environment variables
82+
# Set environment variables (Updated Names)
6983
ENV PYTHONUNBUFFERED=1
7084
ENV BROWSER_USE_LOGGING_LEVEL=info
71-
ENV CHROME_PATH=/ms-playwright/chromium-*/chrome-linux/chrome
85+
# BROWSER_PATH will be determined by Patchright installation, supervisord will find it.
7286
ENV ANONYMIZED_TELEMETRY=false
7387
ENV DISPLAY=:99
7488
ENV RESOLUTION=1920x1080x24
75-
ENV VNC_PASSWORD=vncpassword
76-
ENV CHROME_PERSISTENT_SESSION=true
89+
ENV VNC_PASSWORD=youvncpassword
90+
ENV KEEP_BROWSER_OPEN=true
7791
ENV RESOLUTION_WIDTH=1920
7892
ENV RESOLUTION_HEIGHT=1080
7993

8094
# Set up supervisor configuration
8195
RUN mkdir -p /var/log/supervisor
8296
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
8397

84-
EXPOSE 7788 6080 5901
98+
EXPOSE 7788 6080 5901 9222
8599

86-
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
100+
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]

Dockerfile.arm64

Lines changed: 0 additions & 85 deletions
This file was deleted.

README.md

Lines changed: 42 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@ We would like to officially thank [WarmShao](https://github.com/warmshao) for hi
2323

2424
## Installation Guide
2525

26-
### Prerequisites
27-
- Python 3.11 or higher
28-
- Git (for cloning the repository)
29-
3026
### Option 1: Local Installation
3127

3228
Read the [quickstart guide](https://docs.browser-use.com/quickstart#prepare-the-environment) or follow the steps below to get started.
@@ -65,10 +61,13 @@ Install Python packages:
6561
uv pip install -r requirements.txt
6662
```
6763

68-
Install Browsers in Playwright:
69-
You can install specific browsers by running:
64+
Install Browsers in Patchright.
65+
```bash
66+
patchright install
67+
```
68+
Or you can install specific browsers by running:
7069
```bash
71-
patchright install chromium
70+
patchright install chromium --with-deps --no-shell
7271
```
7372

7473
#### Step 4: Configure Environment
@@ -83,6 +82,42 @@ cp .env.example .env
8382
```
8483
2. Open `.env` in your preferred text editor and add your API keys and other settings
8584

85+
#### Local Setup
86+
1. **Run the WebUI:**
87+
After completing the installation steps above, start the application:
88+
```bash
89+
python webui.py --ip 127.0.0.1 --port 7788
90+
```
91+
2. WebUI options:
92+
- `--ip`: The IP address to bind the WebUI to. Default is `127.0.0.1`.
93+
- `--port`: The port to bind the WebUI to. Default is `7788`.
94+
- `--theme`: The theme for the user interface. Default is `Ocean`.
95+
- **Default**: The standard theme with a balanced design.
96+
- **Soft**: A gentle, muted color scheme for a relaxed viewing experience.
97+
- **Monochrome**: A grayscale theme with minimal color for simplicity and focus.
98+
- **Glass**: A sleek, semi-transparent design for a modern appearance.
99+
- **Origin**: A classic, retro-inspired theme for a nostalgic feel.
100+
- **Citrus**: A vibrant, citrus-inspired palette with bright and fresh colors.
101+
- **Ocean** (default): A blue, ocean-inspired theme providing a calming effect.
102+
- `--dark-mode`: Enables dark mode for the user interface.
103+
3. **Access the WebUI:** Open your web browser and navigate to `http://127.0.0.1:7788`.
104+
4. **Using Your Own Browser(Optional):**
105+
- Set `CHROME_PATH` to the executable path of your browser and `CHROME_USER_DATA` to the user data directory of your browser. Leave `CHROME_USER_DATA` empty if you want to use local user data.
106+
- Windows
107+
```env
108+
CHROME_PATH="C:\Program Files\Google\Chrome\Application\chrome.exe"
109+
CHROME_USER_DATA="C:\Users\YourUsername\AppData\Local\Google\Chrome\User Data"
110+
```
111+
> Note: Replace `YourUsername` with your actual Windows username for Windows systems.
112+
- Mac
113+
```env
114+
CHROME_PATH="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
115+
CHROME_USER_DATA="/Users/YourUsername/Library/Application Support/Google/Chrome"
116+
```
117+
- Close all Chrome windows
118+
- Open the WebUI in a non-Chrome browser, such as Firefox or Edge. This is important because the persistent browser context will use the Chrome data when running the agent.
119+
- Check the "Use Own Browser" option within the Browser Settings.
120+
86121
### Option 2: Docker Installation
87122

88123
#### Prerequisites
@@ -118,95 +153,12 @@ docker compose up --build
118153
CHROME_PERSISTENT_SESSION=true docker compose up --build
119154
```
120155

121-
122156
4. Access the Application:
123157
- Web Interface: Open `http://localhost:7788` in your browser
124158
- VNC Viewer (for watching browser interactions): Open `http://localhost:6080/vnc.html`
125159
- Default VNC password: "youvncpassword"
126160
- Can be changed by setting `VNC_PASSWORD` in your `.env` file
127161

128-
## Usage
129-
130-
### Local Setup
131-
1. **Run the WebUI:**
132-
After completing the installation steps above, start the application:
133-
```bash
134-
python webui.py --ip 127.0.0.1 --port 7788
135-
```
136-
2. WebUI options:
137-
- `--ip`: The IP address to bind the WebUI to. Default is `127.0.0.1`.
138-
- `--port`: The port to bind the WebUI to. Default is `7788`.
139-
- `--theme`: The theme for the user interface. Default is `Ocean`.
140-
- **Default**: The standard theme with a balanced design.
141-
- **Soft**: A gentle, muted color scheme for a relaxed viewing experience.
142-
- **Monochrome**: A grayscale theme with minimal color for simplicity and focus.
143-
- **Glass**: A sleek, semi-transparent design for a modern appearance.
144-
- **Origin**: A classic, retro-inspired theme for a nostalgic feel.
145-
- **Citrus**: A vibrant, citrus-inspired palette with bright and fresh colors.
146-
- **Ocean** (default): A blue, ocean-inspired theme providing a calming effect.
147-
- `--dark-mode`: Enables dark mode for the user interface.
148-
3. **Access the WebUI:** Open your web browser and navigate to `http://127.0.0.1:7788`.
149-
4. **Using Your Own Browser(Optional):**
150-
- Set `CHROME_PATH` to the executable path of your browser and `CHROME_USER_DATA` to the user data directory of your browser. Leave `CHROME_USER_DATA` empty if you want to use local user data.
151-
- Windows
152-
```env
153-
CHROME_PATH="C:\Program Files\Google\Chrome\Application\chrome.exe"
154-
CHROME_USER_DATA="C:\Users\YourUsername\AppData\Local\Google\Chrome\User Data"
155-
```
156-
> Note: Replace `YourUsername` with your actual Windows username for Windows systems.
157-
- Mac
158-
```env
159-
CHROME_PATH="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
160-
CHROME_USER_DATA="/Users/YourUsername/Library/Application Support/Google/Chrome"
161-
```
162-
- Close all Chrome windows
163-
- Open the WebUI in a non-Chrome browser, such as Firefox or Edge. This is important because the persistent browser context will use the Chrome data when running the agent.
164-
- Check the "Use Own Browser" option within the Browser Settings.
165-
5. **Keep Browser Open(Optional):**
166-
- Set `CHROME_PERSISTENT_SESSION=true` in the `.env` file.
167-
168-
### Docker Setup
169-
1. **Environment Variables:**
170-
- All configuration is done through the `.env` file
171-
- Available environment variables:
172-
```
173-
# LLM API Keys
174-
OPENAI_API_KEY=your_key_here
175-
ANTHROPIC_API_KEY=your_key_here
176-
GOOGLE_API_KEY=your_key_here
177-
178-
# Browser Settings
179-
CHROME_PERSISTENT_SESSION=true # Set to true to keep browser open between AI tasks
180-
RESOLUTION=1920x1080x24 # Custom resolution format: WIDTHxHEIGHTxDEPTH
181-
RESOLUTION_WIDTH=1920 # Custom width in pixels
182-
RESOLUTION_HEIGHT=1080 # Custom height in pixels
183-
184-
# VNC Settings
185-
VNC_PASSWORD=your_vnc_password # Optional, defaults to "vncpassword"
186-
```
187-
188-
2. **Platform Support:**
189-
- Supports both AMD64 and ARM64 architectures
190-
- For ARM64 systems (e.g., Apple Silicon Macs), the container will automatically use the appropriate image
191-
192-
3. **Browser Persistence Modes:**
193-
- **Default Mode (CHROME_PERSISTENT_SESSION=false):**
194-
- Browser opens and closes with each AI task
195-
- Clean state for each interaction
196-
- Lower resource usage
197-
198-
- **Persistent Mode (CHROME_PERSISTENT_SESSION=true):**
199-
- Browser stays open between AI tasks
200-
- Maintains history and state
201-
- Allows viewing previous AI interactions
202-
- Set in `.env` file or via environment variable when starting container
203-
204-
4. **Viewing Browser Interactions:**
205-
- Access the noVNC viewer at `http://localhost:6080/vnc.html`
206-
- Enter the VNC password (default: "vncpassword" or what you set in VNC_PASSWORD)
207-
- Direct VNC access available on port 5900 (mapped to container port 5901)
208-
- You can now see all browser interactions in real-time
209-
210162
5. **Container Management:**
211163
```bash
212164
# Start with persistent browser

0 commit comments

Comments
 (0)