File size: 1,468 Bytes
9e57130 ec94fc1 6533818 ec94fc1 f4df84c | 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 | FROM python:3.12-slim
# Playwright/Chromium system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
# Chromium dependencies
libnss3 \
libnspr4 \
libatk1.0-0 \
libatk-bridge2.0-0 \
libcups2 \
libdrm2 \
libxkbcommon0 \
libxcomposite1 \
libxdamage1 \
libxrandr2 \
libgbm1 \
libpango-1.0-0 \
libcairo2 \
libasound2 \
libatspi2.0-0 \
libxshmfence1 \
# Font rendering
fonts-liberation \
fontconfig \
# General utilities
wget \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Install Python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Set browser path BEFORE install so Playwright puts browsers here
ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright
# Install Playwright Chromium browser + all required system deps
RUN playwright install --with-deps chromium
# Copy application code
COPY app/ ./app/
# Copy static assets (fonts & images used for PDF rendering)
COPY fonts/ ./fonts/
COPY images/ ./images/
# Copy env example as fallback
COPY .env.example .env.example
# Hugging Face Spaces uses port 7860 by default
ENV PORT=7860
EXPOSE 7860
# Production command — single worker to stay within HF Spaces memory limits
# Playwright + Chromium is memory-heavy; 2 workers causes OOM restarts
CMD ["sh", "-c", "uvicorn app.main:app --host 0.0.0.0 --port ${PORT:-7860} --workers 1 --timeout-keep-alive 120"]
|