Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +19 -7
Dockerfile
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
# syntax=docker/dockerfile:1.6
|
|
|
|
| 2 |
ARG PY_BASE=python:3.9-slim-bullseye
|
| 3 |
FROM ${PY_BASE}
|
| 4 |
|
|
@@ -9,11 +10,12 @@ ENV PYTHONDONTWRITEBYTECODE=1 \
|
|
| 9 |
OMP_NUM_THREADS=1 \
|
| 10 |
TRANSFORMERS_CACHE=/cache/hf
|
| 11 |
|
| 12 |
-
#
|
| 13 |
ARG DEPS_REFRESH=2025-09-07-06
|
| 14 |
ENV DEPS_REFRESH=$DEPS_REFRESH
|
| 15 |
RUN echo "CACHEBUSTER=$DEPS_REFRESH"
|
| 16 |
|
|
|
|
| 17 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 18 |
ca-certificates curl \
|
| 19 |
tesseract-ocr tesseract-ocr-eng tesseract-ocr-osd \
|
|
@@ -25,29 +27,39 @@ ENV TESSDATA_PREFIX=/usr/share/tesseract-ocr/4.00/tessdata
|
|
| 25 |
WORKDIR /app
|
| 26 |
COPY requirements.txt .
|
| 27 |
|
|
|
|
| 28 |
RUN python -m pip install --upgrade pip setuptools wheel \
|
| 29 |
&& pip install --no-cache-dir -r requirements.txt
|
| 30 |
|
| 31 |
-
# Install spaCy model
|
| 32 |
RUN pip install --no-deps \
|
| 33 |
"en_core_web_sm @ https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.2.0/en_core_web_sm-3.2.0-py3-none-any.whl"
|
| 34 |
|
| 35 |
-
#
|
| 36 |
RUN python - <<'PY'
|
| 37 |
import sys, pkgutil
|
| 38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
print("python:", sys.version.split()[0])
|
| 40 |
-
|
| 41 |
-
print("
|
| 42 |
-
print("spacy:", spacy.__version__, "thinc:", thinc.__version__)
|
| 43 |
print("has en_core_web_sm:", bool(pkgutil.find_loader("en_core_web_sm")))
|
| 44 |
PY
|
| 45 |
|
|
|
|
| 46 |
COPY . .
|
|
|
|
|
|
|
| 47 |
RUN mkdir -p /cache/hf /tmp && chmod -R 777 /cache /tmp
|
| 48 |
|
| 49 |
ENV PORT=8000
|
| 50 |
EXPOSE 8000
|
|
|
|
| 51 |
HEALTHCHECK --interval=30s --timeout=10s --retries=3 \
|
| 52 |
CMD curl -fsS "http://127.0.0.1:${PORT}/health" || exit 1
|
| 53 |
|
|
|
|
| 1 |
# syntax=docker/dockerfile:1.6
|
| 2 |
+
|
| 3 |
ARG PY_BASE=python:3.9-slim-bullseye
|
| 4 |
FROM ${PY_BASE}
|
| 5 |
|
|
|
|
| 10 |
OMP_NUM_THREADS=1 \
|
| 11 |
TRANSFORMERS_CACHE=/cache/hf
|
| 12 |
|
| 13 |
+
# Force a rebuild when you tweak deps
|
| 14 |
ARG DEPS_REFRESH=2025-09-07-06
|
| 15 |
ENV DEPS_REFRESH=$DEPS_REFRESH
|
| 16 |
RUN echo "CACHEBUSTER=$DEPS_REFRESH"
|
| 17 |
|
| 18 |
+
# System deps (tesseract + libs for opencv wheels)
|
| 19 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 20 |
ca-certificates curl \
|
| 21 |
tesseract-ocr tesseract-ocr-eng tesseract-ocr-osd \
|
|
|
|
| 27 |
WORKDIR /app
|
| 28 |
COPY requirements.txt .
|
| 29 |
|
| 30 |
+
# Install python deps
|
| 31 |
RUN python -m pip install --upgrade pip setuptools wheel \
|
| 32 |
&& pip install --no-cache-dir -r requirements.txt
|
| 33 |
|
| 34 |
+
# Install spaCy model matching spaCy 3.2.x WITHOUT pulling new deps
|
| 35 |
RUN pip install --no-deps \
|
| 36 |
"en_core_web_sm @ https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.2.0/en_core_web_sm-3.2.0-py3-none-any.whl"
|
| 37 |
|
| 38 |
+
# Robust version dump (no __version__ attribute assumptions)
|
| 39 |
RUN python - <<'PY'
|
| 40 |
import sys, pkgutil
|
| 41 |
+
try:
|
| 42 |
+
import importlib.metadata as md
|
| 43 |
+
except ImportError:
|
| 44 |
+
import importlib_metadata as md # py3.8 fallback (not used here)
|
| 45 |
+
def v(name):
|
| 46 |
+
try: return md.version(name)
|
| 47 |
+
except md.PackageNotFoundError: return "not-installed"
|
| 48 |
print("python:", sys.version.split()[0])
|
| 49 |
+
for name in ("pydantic","typing-extensions","spacy","thinc","en-core-web-sm"):
|
| 50 |
+
print(f"{name}:", v(name))
|
|
|
|
| 51 |
print("has en_core_web_sm:", bool(pkgutil.find_loader("en_core_web_sm")))
|
| 52 |
PY
|
| 53 |
|
| 54 |
+
# App code
|
| 55 |
COPY . .
|
| 56 |
+
|
| 57 |
+
# Writable caches
|
| 58 |
RUN mkdir -p /cache/hf /tmp && chmod -R 777 /cache /tmp
|
| 59 |
|
| 60 |
ENV PORT=8000
|
| 61 |
EXPOSE 8000
|
| 62 |
+
|
| 63 |
HEALTHCHECK --interval=30s --timeout=10s --retries=3 \
|
| 64 |
CMD curl -fsS "http://127.0.0.1:${PORT}/health" || exit 1
|
| 65 |
|