File size: 1,886 Bytes
a3e694b
 
 
 
565d677
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4257ee1
565d677
 
 
 
a3e694b
565d677
a3e694b
 
 
6be1c8b
 
 
 
 
 
 
 
 
 
d1abc9e
 
 
 
565d677
 
a3e694b
 
565d677
 
 
 
 
 
 
a3e694b
 
565d677
 
 
 
 
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
FROM python:3.12-slim

WORKDIR /app

# Install system dependencies for Playwright and Chromium
RUN apt-get update && apt-get install -y \
    # Build tools
    build-essential \
    git \
    # Chromium browser and driver
    chromium \
    chromium-driver \
    # Playwright dependencies
    libnss3 \
    libnspr4 \
    libatk1.0-0 \
    libatk-bridge2.0-0 \
    libcups2 \
    libdrm2 \
    libdbus-1-3 \
    libxkbcommon0 \
    libxcomposite1 \
    libxdamage1 \
    libxfixes3 \
    libxrandr2 \
    libgbm1 \
    libasound2 \
    libatspi2.0-0 \
    libxshmfence1 \
    # Utilities
    curl \
    wget \
    ca-certificates \
    fonts-liberation \
    && rm -rf /var/lib/apt/lists/*

# Copy and install Python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Find Chromium installation and create symlink if needed
RUN if [ -f /usr/bin/chromium-browser ]; then \
        ln -sf /usr/bin/chromium-browser /usr/bin/chromium; \
    elif [ -f /usr/lib/chromium/chromium ]; then \
        ln -sf /usr/lib/chromium/chromium /usr/bin/chromium; \
    fi

# Verify Chromium is accessible
RUN which chromium || (echo "ERROR: Chromium not found!" && exit 1)

# Set Playwright to use system Chromium
ENV PLAYWRIGHT_BROWSERS_PATH=0
ENV PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
ENV PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH=/usr/bin/chromium

# Copy application code
COPY . .

# Set Streamlit configuration for HuggingFace Spaces
ENV STREAMLIT_SERVER_PORT=7860
ENV STREAMLIT_SERVER_ADDRESS=0.0.0.0
ENV STREAMLIT_SERVER_HEADLESS=true
ENV STREAMLIT_BROWSER_GATHER_USAGE_STATS=false

# Expose Streamlit port
EXPOSE 7860

# Health check
HEALTHCHECK CMD curl --fail http://localhost:7860/_stcore/health || exit 1

# Run Streamlit (corrected app file path from main.py to app.py)
CMD ["streamlit", "run", "app/app.py", "--server.port=7860", "--server.address=0.0.0.0"]