Spaces:
Sleeping
Sleeping
Upload dockerfile
Browse files- dockerfile +48 -0
dockerfile
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# syntax=docker/dockerfile:1.6
|
| 2 |
+
|
| 3 |
+
# ===== Python base (3.9) =====
|
| 4 |
+
ARG PY_BASE=python:3.9-slim
|
| 5 |
+
FROM ${PY_BASE}
|
| 6 |
+
|
| 7 |
+
ENV PYTHONDONTWRITEBYTECODE=1 \
|
| 8 |
+
PYTHONUNBUFFERED=1 \
|
| 9 |
+
PIP_NO_CACHE_DIR=1 \
|
| 10 |
+
TOKENIZERS_PARALLELISM=false \
|
| 11 |
+
OMP_NUM_THREADS=1 \
|
| 12 |
+
TRANSFORMERS_CACHE=/cache/hf
|
| 13 |
+
|
| 14 |
+
# ---- System deps (Tesseract + libs OpenCV wheels expect) ----
|
| 15 |
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 16 |
+
ca-certificates curl \
|
| 17 |
+
tesseract-ocr tesseract-ocr-eng tesseract-ocr-osd \
|
| 18 |
+
libgl1 libglib2.0-0 \
|
| 19 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 20 |
+
|
| 21 |
+
# Tesseract language data path (Debian/Ubuntu)
|
| 22 |
+
ENV TESSDATA_PREFIX=/usr/share/tesseract-ocr/4.00/tessdata
|
| 23 |
+
|
| 24 |
+
# ---- App setup ----
|
| 25 |
+
WORKDIR /app
|
| 26 |
+
|
| 27 |
+
# Install Python deps first for better layer caching
|
| 28 |
+
COPY requirements.txt .
|
| 29 |
+
RUN python -m pip install --upgrade pip setuptools wheel \
|
| 30 |
+
&& pip install -r requirements.txt \
|
| 31 |
+
&& 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 \
|
| 32 |
+
&& python -m spacy validate
|
| 33 |
+
|
| 34 |
+
# Copy the rest of your app
|
| 35 |
+
COPY . .
|
| 36 |
+
|
| 37 |
+
# Writable caches (for HF/torch/tmp)
|
| 38 |
+
RUN mkdir -p /cache/hf /tmp && chmod -R 777 /cache /tmp
|
| 39 |
+
|
| 40 |
+
# App port & healthcheck
|
| 41 |
+
ENV PORT=8000
|
| 42 |
+
EXPOSE 8000
|
| 43 |
+
|
| 44 |
+
HEALTHCHECK --interval=30s --timeout=10s --retries=3 \
|
| 45 |
+
CMD curl -fsS "http://127.0.0.1:${PORT}/health" || exit 1
|
| 46 |
+
|
| 47 |
+
# Use $PORT when present (Render sets it), default to 8000 locally
|
| 48 |
+
CMD ["sh","-c","uvicorn backend:app --host 0.0.0.0 --port ${PORT:-8000}"]
|