Spaces:
Sleeping
Sleeping
File size: 1,242 Bytes
0b24cca 862cbed 0b24cca 862cbed 0b24cca 2ba385f 0b24cca 2ba385f 0b24cca bb6107f 862cbed 0b24cca 862cbed 0b24cca | 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 | FROM python:3.11-slim
# System deps for lxml, Pillow, and PaddleOCR
RUN apt-get update && apt-get install -y --no-install-recommends \
libxml2 libxslt1.1 libjpeg62-turbo libwebp7 libtiff6 \
libgl1 libglib2.0-0 libgomp1 \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Install Python deps first (layer caching)
COPY pyproject.toml README.md ./
RUN pip install --no-cache-dir .
# Copy application code and frontend
COPY src/ src/
COPY frontend/ frontend/
COPY AGENTS.md ./
# HF Spaces requires a non-root user
RUN useradd -m -u 1000 appuser \
&& mkdir -p /app/data /data \
&& chown -R appuser:appuser /app /data
USER appuser
# Pre-download PaddleOCR models at build time (avoids first-request delay)
RUN python -c "from paddleocr import PaddleOCR; PaddleOCR(use_angle_cls=True, lang='fr', show_log=False)" 2>/dev/null || true
# Default storage root — overridden in Space mode via /data
ENV STORAGE_ROOT=/app/data
ENV HOST=0.0.0.0
ENV PORT=7860
EXPOSE 7860
HEALTHCHECK --interval=30s --timeout=5s --start-period=30s --retries=3 \
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:7860/health')" || exit 1
CMD ["uvicorn", "src.app.main:app", "--host", "0.0.0.0", "--port", "7860"]
|