Spaces:
Runtime error
Runtime error
| FROM python:3.10-slim | |
| # System libraries PaddleOCR / OpenCV need at runtime. | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| libgl1 \ | |
| libglib2.0-0 \ | |
| libgomp1 \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Hugging Face Spaces runs the container as uid 1000. Create that user and a | |
| # writable home so model weights and caches have somewhere to live. | |
| RUN useradd -m -u 1000 user | |
| USER user | |
| ENV HOME=/home/user \ | |
| PATH=/home/user/.local/bin:$PATH \ | |
| PYTHONUNBUFFERED=1 | |
| WORKDIR /home/user/app | |
| # Install Python dependencies first so the layer caches across code changes. | |
| COPY --chown=user requirements.txt . | |
| RUN pip install --no-cache-dir --upgrade pip \ | |
| && pip install --no-cache-dir -r requirements.txt | |
| # Pre-download the English PP-OCRv4 weights at build time so the first visitor | |
| # does not wait for the download. A network blip here is non-fatal: the app | |
| # downloads them on first use anyway. | |
| RUN python -c "from paddleocr import PaddleOCR; PaddleOCR(use_angle_cls=True, lang='en', show_log=False)" \ | |
| || echo "weight prewarm skipped; will download at runtime" | |
| # Application code. | |
| COPY --chown=user . . | |
| EXPOSE 7860 | |
| CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] | |