Sluethink / Dockerfile
topGdev's picture
Add Playwright system dependencies
2adf3e7
# 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"]