Spaces:
Running
Running
| # Extractor service for Hugging Face Spaces (Docker SDK). | |
| # HF free CPU tier gives 16GB RAM — no more OOM from PDF/OCR rendering. | |
| FROM python:3.13-slim | |
| # System dep: tesseract for OCR (the engine shells out to the `tesseract` CLI). | |
| RUN apt-get update \ | |
| && apt-get install -y --no-install-recommends tesseract-ocr \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # HF Spaces run containers as uid 1000; set up a matching non-root user + writable home. | |
| RUN useradd -m -u 1000 user | |
| USER user | |
| ENV HOME=/home/user \ | |
| PATH=/home/user/.local/bin:$PATH \ | |
| PYTHONUNBUFFERED=1 \ | |
| EBS_WORK_DIR=/home/user/app/_work | |
| WORKDIR /home/user/app | |
| # Install Python deps first (better layer caching). | |
| COPY --chown=user:user requirements.txt . | |
| RUN pip install --no-cache-dir --user -r requirements.txt | |
| # App code + a writable work dir for uploads/OCR temp images. | |
| COPY --chown=user:user . . | |
| RUN mkdir -p /home/user/app/_work | |
| # HF Spaces expect the app on port 7860. | |
| EXPOSE 7860 | |
| CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"] | |