Spaces:
Sleeping
Sleeping
| # syntax=docker/dockerfile:1.6 | |
| # ===== Python base (3.9) ===== | |
| ARG PY_BASE=python:3.9-slim | |
| FROM ${PY_BASE} | |
| ENV PYTHONDONTWRITEBYTECODE=1 \ | |
| PYTHONUNBUFFERED=1 \ | |
| PIP_NO_CACHE_DIR=1 \ | |
| TOKENIZERS_PARALLELISM=false \ | |
| OMP_NUM_THREADS=1 \ | |
| TRANSFORMERS_CACHE=/cache/hf | |
| # ---- System deps (Tesseract + libs OpenCV wheels expect) ---- | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| ca-certificates curl \ | |
| tesseract-ocr tesseract-ocr-eng tesseract-ocr-osd \ | |
| libgl1 libglib2.0-0 \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Tesseract language data path (Debian/Ubuntu) | |
| ENV TESSDATA_PREFIX=/usr/share/tesseract-ocr/4.00/tessdata | |
| # ---- App setup ---- | |
| WORKDIR /app | |
| # Install Python deps first for better layer caching | |
| COPY requirements.txt . | |
| RUN python -m pip install --upgrade pip setuptools wheel \ | |
| && pip install -r requirements.txt \ | |
| && pip install https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.6.0/en_core_web_sm-3.6.0-py3-none-any.whl \ | |
| && python -m spacy validate | |
| # Copy the rest of your app | |
| COPY . . | |
| # Writable caches (for HF/torch/tmp) | |
| RUN mkdir -p /cache/hf /tmp && chmod -R 777 /cache /tmp | |
| # App port & healthcheck | |
| ENV PORT=8000 | |
| EXPOSE 8000 | |
| HEALTHCHECK --interval=30s --timeout=10s --retries=3 \ | |
| CMD curl -fsS "http://127.0.0.1:${PORT}/health" || exit 1 | |
| # Use $PORT when present (Render sets it), default to 8000 locally | |
| CMD ["sh","-c","uvicorn backend:app --host 0.0.0.0 --port ${PORT:-8000}"] | |