forked from browser-use/web-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request browser-use#73 from casistack/feat--add-Docker-sup…
…port-and-environment-configuration-updated Feat add docker support and environment configuration updated
- Loading branch information
Showing
9 changed files
with
497 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
FROM python:3.11-slim | ||
|
||
# Install system dependencies | ||
RUN apt-get update && apt-get install -y \ | ||
wget \ | ||
gnupg \ | ||
curl \ | ||
unzip \ | ||
xvfb \ | ||
libgconf-2-4 \ | ||
libxss1 \ | ||
libnss3 \ | ||
libnspr4 \ | ||
libasound2 \ | ||
libatk1.0-0 \ | ||
libatk-bridge2.0-0 \ | ||
libcups2 \ | ||
libdbus-1-3 \ | ||
libdrm2 \ | ||
libgbm1 \ | ||
libgtk-3-0 \ | ||
libxcomposite1 \ | ||
libxdamage1 \ | ||
libxfixes3 \ | ||
libxrandr2 \ | ||
xdg-utils \ | ||
fonts-liberation \ | ||
dbus \ | ||
xauth \ | ||
xvfb \ | ||
x11vnc \ | ||
tigervnc-tools \ | ||
supervisor \ | ||
net-tools \ | ||
procps \ | ||
git \ | ||
python3-numpy \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# Install noVNC | ||
RUN git clone https://github.com/novnc/noVNC.git /opt/novnc \ | ||
&& git clone https://github.com/novnc/websockify /opt/novnc/utils/websockify \ | ||
&& ln -s /opt/novnc/vnc.html /opt/novnc/index.html | ||
|
||
# Install Chrome | ||
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \ | ||
&& echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list \ | ||
&& apt-get update \ | ||
&& apt-get install -y google-chrome-stable \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# Set up working directory | ||
WORKDIR /app | ||
|
||
# Copy requirements and install Python dependencies | ||
COPY requirements.txt . | ||
RUN pip install --no-cache-dir -r requirements.txt | ||
|
||
# Install Playwright and browsers with system dependencies | ||
ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright | ||
RUN playwright install --with-deps chromium | ||
RUN playwright install-deps | ||
|
||
# Copy the application code | ||
COPY . . | ||
|
||
# Set environment variables | ||
ENV PYTHONUNBUFFERED=1 | ||
ENV BROWSER_USE_LOGGING_LEVEL=info | ||
ENV CHROME_PATH=/usr/bin/google-chrome | ||
ENV ANONYMIZED_TELEMETRY=false | ||
ENV DISPLAY=:99 | ||
ENV RESOLUTION=1920x1080x24 | ||
ENV VNC_PASSWORD=vncpassword | ||
|
||
# Set up supervisor configuration | ||
RUN mkdir -p /var/log/supervisor | ||
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf | ||
|
||
EXPOSE 7788 6080 5900 | ||
|
||
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
services: | ||
browser-use-webui: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile | ||
ports: | ||
- "7788:7788" # Gradio default port | ||
- "6080:6080" # noVNC web interface | ||
- "5900:5900" # VNC port | ||
- "9222:9222" # Chrome remote debugging port | ||
environment: | ||
- OPENAI_ENDPOINT=${OPENAI_ENDPOINT:-https://api.openai.com/v1} | ||
- OPENAI_API_KEY=${OPENAI_API_KEY:-} | ||
- ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY:-} | ||
- GOOGLE_API_KEY=${GOOGLE_API_KEY:-} | ||
- AZURE_OPENAI_ENDPOINT=${AZURE_OPENAI_ENDPOINT:-} | ||
- AZURE_OPENAI_API_KEY=${AZURE_OPENAI_API_KEY:-} | ||
- DEEPSEEK_ENDPOINT=${DEEPSEEK_ENDPOINT:-https://api.deepseek.com} | ||
- DEEPSEEK_API_KEY=${DEEPSEEK_API_KEY:-} | ||
- BROWSER_USE_LOGGING_LEVEL=${BROWSER_USE_LOGGING_LEVEL:-info} | ||
- ANONYMIZED_TELEMETRY=false | ||
- CHROME_PATH=/usr/bin/google-chrome | ||
- CHROME_USER_DATA=/app/data/chrome_data | ||
- CHROME_PERSISTENT_SESSION=${CHROME_PERSISTENT_SESSION:-false} | ||
- DISPLAY=:99 | ||
- PLAYWRIGHT_BROWSERS_PATH=/ms-playwright | ||
- RESOLUTION=${RESOLUTION:-1920x1080x24} | ||
- RESOLUTION_WIDTH=${RESOLUTION_WIDTH:-1920} | ||
- RESOLUTION_HEIGHT=${RESOLUTION_HEIGHT:-1080} | ||
- VNC_PASSWORD=${VNC_PASSWORD:-vncpassword} | ||
- PERSISTENT_BROWSER_PORT=9222 | ||
- PERSISTENT_BROWSER_HOST=localhost | ||
- CHROME_DEBUGGING_PORT=9222 | ||
- CHROME_DEBUGGING_HOST=localhost | ||
volumes: | ||
- ./data:/app/data | ||
- ./data/chrome_data:/app/data/chrome_data | ||
- /tmp/.X11-unix:/tmp/.X11-unix | ||
restart: unless-stopped | ||
shm_size: '2gb' | ||
cap_add: | ||
- SYS_ADMIN | ||
security_opt: | ||
- seccomp=unconfined | ||
tmpfs: | ||
- /tmp | ||
healthcheck: | ||
test: ["CMD", "nc", "-z", "localhost", "5900"] | ||
interval: 10s | ||
timeout: 5s | ||
retries: 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# -*- coding: utf-8 -*- | ||
# @Time : 2025/1/6 | ||
# @Author : wenshao | ||
# @ProjectName: browser-use-webui | ||
# @FileName: config.py | ||
|
||
import os | ||
from dataclasses import dataclass | ||
from typing import Optional | ||
|
||
|
||
@dataclass | ||
class BrowserPersistenceConfig: | ||
"""Configuration for browser persistence""" | ||
|
||
persistent_session: bool = False | ||
user_data_dir: Optional[str] = None | ||
debugging_port: Optional[int] = None | ||
debugging_host: Optional[str] = None | ||
|
||
@classmethod | ||
def from_env(cls) -> "BrowserPersistenceConfig": | ||
"""Create config from environment variables""" | ||
return cls( | ||
persistent_session=os.getenv("CHROME_PERSISTENT_SESSION", "").lower() | ||
== "true", | ||
user_data_dir=os.getenv("CHROME_USER_DATA"), | ||
debugging_port=int(os.getenv("CHROME_DEBUGGING_PORT", "9222")), | ||
debugging_host=os.getenv("CHROME_DEBUGGING_HOST", "localhost"), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.