Skip to content

Commit e4a3f84

Browse files
committed
Add ARM64 support for M-series Mac with optimized Docker configurations
1 parent 5bc4978 commit e4a3f84

File tree

6 files changed

+128
-32
lines changed

6 files changed

+128
-32
lines changed

Dockerfile

+3-5
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,8 @@ RUN git clone https://github.com/novnc/noVNC.git /opt/novnc \
4646
&& git clone https://github.com/novnc/websockify /opt/novnc/utils/websockify \
4747
&& ln -s /opt/novnc/vnc.html /opt/novnc/index.html
4848

49-
# Install Chrome
50-
RUN curl -fsSL https://dl.google.com/linux/linux_signing_key.pub | gpg --dearmor -o /usr/share/keyrings/google-chrome.gpg \
51-
&& echo "deb [arch=amd64 signed-by=/usr/share/keyrings/google-chrome.gpg] http://dl.google.com/linux/chrome/deb/ stable main" | tee /etc/apt/sources.list.d/google-chrome.list
49+
# Set platform for ARM64 compatibility
50+
ARG TARGETPLATFORM=linux/arm64
5251

5352
# Set up working directory
5453
WORKDIR /app
@@ -61,15 +60,14 @@ RUN pip install --no-cache-dir -r requirements.txt
6160
ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright
6261
RUN playwright install --with-deps chromium
6362
RUN playwright install-deps
64-
RUN apt-get install -y google-chrome-stable
6563

6664
# Copy the application code
6765
COPY . .
6866

6967
# Set environment variables
7068
ENV PYTHONUNBUFFERED=1
7169
ENV BROWSER_USE_LOGGING_LEVEL=info
72-
ENV CHROME_PATH=/usr/bin/google-chrome
70+
ENV CHROME_PATH=/ms-playwright/chromium-*/chrome-linux/chrome
7371
ENV ANONYMIZED_TELEMETRY=false
7472
ENV DISPLAY=:99
7573
ENV RESOLUTION=1920x1080x24

Dockerfile.arm64

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
FROM python:3.11-slim
2+
3+
# Install system dependencies
4+
RUN apt-get update && apt-get install -y \
5+
wget \
6+
gnupg \
7+
curl \
8+
unzip \
9+
xvfb \
10+
libgconf-2-4 \
11+
libxss1 \
12+
libnss3 \
13+
libnspr4 \
14+
libasound2 \
15+
libatk1.0-0 \
16+
libatk-bridge2.0-0 \
17+
libcups2 \
18+
libdbus-1-3 \
19+
libdrm2 \
20+
libgbm1 \
21+
libgtk-3-0 \
22+
libxcomposite1 \
23+
libxdamage1 \
24+
libxfixes3 \
25+
libxrandr2 \
26+
xdg-utils \
27+
fonts-liberation \
28+
dbus \
29+
xauth \
30+
xvfb \
31+
x11vnc \
32+
tigervnc-tools \
33+
supervisor \
34+
net-tools \
35+
procps \
36+
git \
37+
python3-numpy \
38+
fontconfig \
39+
fonts-dejavu \
40+
fonts-dejavu-core \
41+
fonts-dejavu-extra \
42+
&& rm -rf /var/lib/apt/lists/*
43+
44+
# Install noVNC
45+
RUN git clone https://github.com/novnc/noVNC.git /opt/novnc \
46+
&& git clone https://github.com/novnc/websockify /opt/novnc/utils/websockify \
47+
&& ln -s /opt/novnc/vnc.html /opt/novnc/index.html
48+
49+
# Set platform explicitly for ARM64
50+
ARG TARGETPLATFORM=linux/arm64
51+
52+
# Set up working directory
53+
WORKDIR /app
54+
55+
# Copy requirements and install Python dependencies
56+
COPY requirements.txt .
57+
RUN pip install --no-cache-dir -r requirements.txt
58+
59+
# Install Playwright and browsers with system dependencies optimized for ARM64
60+
ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright
61+
RUN PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 pip install playwright && \
62+
playwright install --with-deps chromium
63+
64+
# Copy the application code
65+
COPY . .
66+
67+
# Set environment variables
68+
ENV PYTHONUNBUFFERED=1
69+
ENV BROWSER_USE_LOGGING_LEVEL=info
70+
ENV CHROME_PATH=/ms-playwright/chromium-*/chrome-linux/chrome
71+
ENV ANONYMIZED_TELEMETRY=false
72+
ENV DISPLAY=:99
73+
ENV RESOLUTION=1920x1080x24
74+
ENV VNC_PASSWORD=vncpassword
75+
ENV CHROME_PERSISTENT_SESSION=true
76+
ENV RESOLUTION_WIDTH=1920
77+
ENV RESOLUTION_HEIGHT=1080
78+
79+
# Set up supervisor configuration
80+
RUN mkdir -p /var/log/supervisor
81+
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
82+
83+
EXPOSE 7788 6080 5900
84+
85+
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]

README.md

+9-3
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ playwright install
8282
4. **Access the Application:**
8383
- WebUI: `http://localhost:7788`
8484
- VNC Viewer (to see browser interactions): `http://localhost:6080/vnc.html`
85+
- Direct VNC access is available on port 5901 (especially useful for Mac users)
8586

8687
Default VNC password is "vncpassword". You can change it by setting the `VNC_PASSWORD` environment variable in your `.env` file.
8788

@@ -146,7 +147,11 @@ playwright install
146147
VNC_PASSWORD=your_vnc_password # Optional, defaults to "vncpassword"
147148
```
148149

149-
2. **Browser Persistence Modes:**
150+
2. **Platform Support:**
151+
- Supports both AMD64 and ARM64 architectures
152+
- For ARM64 systems (e.g., Apple Silicon Macs), the container will automatically use the appropriate image
153+
154+
3. **Browser Persistence Modes:**
150155
- **Default Mode (CHROME_PERSISTENT_SESSION=false):**
151156
- Browser opens and closes with each AI task
152157
- Clean state for each interaction
@@ -158,12 +163,13 @@ playwright install
158163
- Allows viewing previous AI interactions
159164
- Set in `.env` file or via environment variable when starting container
160165

161-
3. **Viewing Browser Interactions:**
166+
4. **Viewing Browser Interactions:**
162167
- Access the noVNC viewer at `http://localhost:6080/vnc.html`
163168
- Enter the VNC password (default: "vncpassword" or what you set in VNC_PASSWORD)
169+
- Direct VNC access available on port 5900 (mapped to container port 5901)
164170
- You can now see all browser interactions in real-time
165171

166-
4. **Container Management:**
172+
5. **Container Management:**
167173
```bash
168174
# Start with persistent browser
169175
CHROME_PERSISTENT_SESSION=true docker compose up -d

docker-compose.yml

+6-4
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ services:
22
browser-use-webui:
33
build:
44
context: .
5-
dockerfile: Dockerfile
5+
dockerfile: ${DOCKERFILE:-Dockerfile}
6+
args:
7+
TARGETPLATFORM: ${TARGETPLATFORM:-linux/amd64}
68
ports:
79
- "7788:7788" # Gradio default port
8-
- "6080:6080" # noVNC web interface
9-
- "5900:5900" # VNC port
10+
- "6080:6081" # noVNC web interface
11+
- "5901:5901" # VNC port
1012
- "9222:9222" # Chrome remote debugging port
1113
environment:
1214
- OPENAI_ENDPOINT=${OPENAI_ENDPOINT:-https://api.openai.com/v1}
@@ -41,7 +43,7 @@ services:
4143
tmpfs:
4244
- /tmp
4345
healthcheck:
44-
test: ["CMD", "nc", "-z", "localhost", "5900"]
46+
test: ["CMD", "nc", "-z", "localhost", "5901"]
4547
interval: 10s
4648
timeout: 5s
4749
retries: 3

entrypoint.sh

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
# Start supervisord in the foreground to properly manage child processes
4+
exec /usr/bin/supervisord -n -c /etc/supervisor/conf.d/supervisord.conf

supervisord.conf

+21-20
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
[supervisord]
2+
user=root
23
nodaemon=true
34
logfile=/dev/stdout
45
logfile_maxbytes=0
@@ -13,6 +14,8 @@ stderr_logfile=/dev/stderr
1314
stderr_logfile_maxbytes=0
1415
priority=100
1516
startsecs=3
17+
stopsignal=TERM
18+
stopwaitsecs=10
1619

1720
[program:vnc_setup]
1821
command=bash -c "mkdir -p ~/.vnc && echo '%(ENV_VNC_PASSWORD)s' | vncpasswd -f > ~/.vnc/passwd && chmod 600 ~/.vnc/passwd && ls -la ~/.vnc/passwd"
@@ -25,48 +28,44 @@ stderr_logfile=/dev/stderr
2528
stderr_logfile_maxbytes=0
2629

2730
[program:x11vnc]
28-
command=bash -c "sleep 3 && DISPLAY=:99 x11vnc -display :99 -forever -shared -rfbauth /root/.vnc/passwd -rfbport 5900 -bg -o /var/log/x11vnc.log"
31+
command=bash -c "mkdir -p /var/log && touch /var/log/x11vnc.log && chmod 666 /var/log/x11vnc.log && sleep 5 && DISPLAY=:99 x11vnc -display :99 -forever -shared -rfbauth /root/.vnc/passwd -rfbport 5901 -o /var/log/x11vnc.log"
2932
autorestart=true
3033
stdout_logfile=/dev/stdout
3134
stdout_logfile_maxbytes=0
3235
stderr_logfile=/dev/stderr
3336
stderr_logfile_maxbytes=0
3437
priority=200
35-
startretries=5
36-
startsecs=5
37-
depends_on=vnc_setup
38+
startretries=10
39+
startsecs=10
40+
stopsignal=TERM
41+
stopwaitsecs=10
42+
depends_on=vnc_setup,xvfb
3843

3944
[program:x11vnc_log]
40-
command=tail -f /var/log/x11vnc.log
45+
command=bash -c "mkdir -p /var/log && touch /var/log/x11vnc.log && tail -f /var/log/x11vnc.log"
4146
autorestart=true
4247
stdout_logfile=/dev/stdout
4348
stdout_logfile_maxbytes=0
4449
stderr_logfile=/dev/stderr
4550
stderr_logfile_maxbytes=0
4651
priority=250
47-
48-
[program:novnc]
49-
command=bash -c "sleep 5 && cd /opt/novnc && ./utils/novnc_proxy --vnc localhost:5900 --listen 0.0.0.0:6080 --web /opt/novnc"
50-
autorestart=true
51-
stdout_logfile=/dev/stdout
52-
stdout_logfile_maxbytes=0
53-
stderr_logfile=/dev/stderr
54-
stderr_logfile_maxbytes=0
55-
priority=300
56-
startretries=5
57-
startsecs=3
52+
stopsignal=TERM
53+
stopwaitsecs=5
5854
depends_on=x11vnc
5955

6056
[program:persistent_browser]
61-
command=bash -c 'mkdir -p /app/data/chrome_data && sleep 8 && google-chrome --user-data-dir=/app/data/chrome_data --window-position=0,0 --window-size=%(ENV_RESOLUTION_WIDTH)s,%(ENV_RESOLUTION_HEIGHT)s --start-maximized --no-sandbox --disable-dev-shm-usage --disable-gpu --disable-software-rasterizer --disable-setuid-sandbox --no-first-run --no-default-browser-check --no-experiments --ignore-certificate-errors --remote-debugging-port=9222 --remote-debugging-address=0.0.0.0 "data:text/html,<html><body style=\"background: \#f0f0f0; margin: 0; display: flex; justify-content: center; align-items: center; height: 100vh; font-family: Arial;\"><h1>Browser Ready for AI Interaction</h1></body></html>"'
57+
environment=START_URL="data:text/html,<html><body><h1>Browser Ready</h1></body></html>"
58+
command=bash -c "mkdir -p /app/data/chrome_data && sleep 8 && $(find /ms-playwright/chromium-*/chrome-linux -name chrome) --user-data-dir=/app/data/chrome_data --window-position=0,0 --window-size=%(ENV_RESOLUTION_WIDTH)s,%(ENV_RESOLUTION_HEIGHT)s --start-maximized --no-sandbox --disable-dev-shm-usage --disable-gpu --disable-software-rasterizer --disable-setuid-sandbox --no-first-run --no-default-browser-check --no-experiments --ignore-certificate-errors --remote-debugging-port=9222 --remote-debugging-address=0.0.0.0 \"$START_URL\""
6259
autorestart=true
6360
stdout_logfile=/dev/stdout
6461
stdout_logfile_maxbytes=0
6562
stderr_logfile=/dev/stderr
6663
stderr_logfile_maxbytes=0
6764
priority=350
68-
startretries=3
69-
startsecs=3
65+
startretries=5
66+
startsecs=10
67+
stopsignal=TERM
68+
stopwaitsecs=15
7069
depends_on=novnc
7170

7271
[program:webui]
@@ -80,4 +79,6 @@ stderr_logfile_maxbytes=0
8079
priority=400
8180
startretries=3
8281
startsecs=3
83-
depends_on=persistent_browser
82+
stopsignal=TERM
83+
stopwaitsecs=10
84+
depends_on=persistent_browser

0 commit comments

Comments
 (0)