File size: 1,658 Bytes
1396463
 
42ea825
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1396463
 
 
 
f464300
 
 
 
 
42ea825
f464300
42ea825
1396463
f464300
1396463
42ea825
 
f464300
42ea825
 
f464300
42ea825
 
 
 
1396463
f464300
42ea825
 
1396463
42ea825
 
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
FROM python:3.12-slim

# Environment setup
ENV PYTHONUNBUFFERED=1 \
    PORT=7860 \
    PLAYWRIGHT_BROWSERS_PATH=/ms-playwright \
    PYTHONDONTWRITEBYTECODE=1 \
    PIP_NO_CACHE_DIR=1

# Install system dependencies for Playwright + Chromium
RUN apt-get update && apt-get install -y --no-install-recommends \
    wget curl git unzip xvfb \
    libnss3 libatk1.0-0 libatk-bridge2.0-0 libcups2 libdrm2 \
    libxkbcommon0 libxcomposite1 libxdamage1 libxfixes3 libxrandr2 \
    libgbm1 libasound2 libpangocairo-1.0-0 libpango-1.0-0 \
    libcairo2 libx11-6 libxext6 libxrender1 fonts-liberation \
    gcc g++ make \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /app

# Create requirements.txt using echo (Docker-compatible)
RUN echo "fastapi>=0.109.0" > requirements.txt && \
    echo "uvicorn[standard]>=0.27.0" >> requirements.txt && \
    echo "playwright>=1.41.0" >> requirements.txt && \
    echo "python-multipart>=0.0.6" >> requirements.txt

# Install Python dependencies
RUN pip install -r requirements.txt

# Install Playwright Chromium browser + deps
RUN playwright install chromium
RUN playwright install-deps chromium 2>/dev/null || true

# Copy application code (single file)
COPY app.py /app/app.py

# Create persistent directories for scripts/results
RUN mkdir -p /app/scripts /app/results && chmod 755 /app/scripts /app/results

# Expose port for Hugging Face Spaces
EXPOSE 7860

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

# Start the application
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--log-level", "info"]