File size: 2,471 Bytes
786ab2f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# ============================================================
# LANDRUN + BROWSER-USE + CHROMIUM - MERGED SYSTEM
# Multi-stage build: Build landrun + Python + Browser-Use + Chromium
# ============================================================

# Stage 1: Build landrun binary from Go source
FROM golang:1.22-bookworm AS builder

WORKDIR /build

# Copy landrun source (from D:\sand\landrun-main\landrun-main)
COPY landrun-main/ ./

# Build landrun with full module context
RUN go mod download && \
    go build -ldflags="-s -w" -o landrun ./cmd/landrun

# Stage 2: Production image with Python + landrun + Browser-Use + Chromium
FROM python:3.11-slim-bookworm

# Install system dependencies + compilers + browser deps
RUN apt-get update && apt-get install -y \
    # Core utilities
    nodejs npm curl procps strace git \
    # Compilers
    gcc g++ make cmake \
    # Browser dependencies (Playwright Chromium)
    libnss3 libnspr4 libatk1.0-0 libatk-bridge2.0-0 \
    libcups2 libdrm2 libxkbcommon0 libxcomposite1 \
    libxdamage1 libxfixes3 libxrandr2 libgbm1 \
    libpango-1.0-0 libcairo2 libasound2 libatspi2.0-0 \
    libxshmfence1 fonts-liberation libappindicator3-1 xdg-utils \
    && rm -rf /var/lib/apt/lists/*

# Copy landrun binary from builder
COPY --from=builder /build/landrun /usr/local/bin/landrun

# Verify landrun works
RUN landrun --version

# Set working directory
WORKDIR /app

# Copy Browser-Use source (from D:\sand\landrun-main\browser-use-main)
COPY browser-use-main/browser_use ./browser_use
COPY browser-use-main/pyproject.toml ./

# Copy Python requirements
COPY requirements.txt .

# Install Python dependencies (Browser-Use + Playwright + FastAPI)
RUN pip install --no-cache-dir -r requirements.txt

# Install Browser-Use in editable mode
RUN pip install -e .

# Install Playwright and Chromium browser
RUN playwright install chromium --with-deps

# Copy application code
COPY app_enhanced.py ./app.py

# Create execution directory
RUN mkdir -p /tmp/sandbox && chmod 777 /tmp/sandbox

# Expose port for Hugging Face Spaces
EXPOSE 7860

# Set environment variables
ENV PYTHONUNBUFFERED=1
ENV HOST=0.0.0.0
ENV PORT=7860
ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright
ENV BROWSER_USE_SETUP_LOGGING=false

# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
    CMD curl -f http://localhost:7860/health || exit 1

# Run FastAPI with uvicorn
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]