File size: 1,265 Bytes
8b959f3
 
 
 
 
88772b5
 
 
43711b9
 
 
2adf3e7
 
88772b5
8b959f3
 
 
 
 
 
 
 
 
 
 
 
88772b5
 
 
8b959f3
 
 
88772b5
8b959f3
 
 
 
 
 
 
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
# Read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
# Based on HF Spaces best practices

FROM python:3.12-slim-bullseye

# Update system packages and install Playwright dependencies
RUN apt-get update && apt-get upgrade -y && \
    apt-get install -y --no-install-recommends \
    libglib2.0-0 libnspr4 libnss3 libdbus-1-3 libcups2 \
    libexpat1 libxcb1 libxkbcommon0 libx11-6 libxcomposite1 \
    libxdamage1 libxext6 libxfixes3 libxrandr2 libcairo2 libpango-1.0-0 \
    libasound2 libatk1.0-0 libatk-bridge2.0-0 libatspi2.0-0 libgbm1 \
    fonts-dejavu fonts-liberation && \
    rm -rf /var/lib/apt/lists/*

# Create non-root user for security
RUN useradd -m -u 1000 user
USER user
ENV PATH="/home/user/.local/bin:$PATH"

WORKDIR /app

# Copy and install requirements
COPY --chown=user ./requirements.txt requirements.txt
RUN pip install --no-cache-dir --upgrade -r requirements.txt

# Copy application code first
COPY --chown=user . /app

# Download NLTK data
RUN python -m nltk.downloader stopwords wordnet punkt_tab

# Install Playwright browsers (after app is copied)
RUN playwright install chromium

# Expose port (HF Spaces uses 7860)
EXPOSE 7860

# Run the application
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]