Spaces:
Sleeping
Sleeping
File size: 2,362 Bytes
0533780 e705a4f 0533780 aaee313 0533780 e705a4f 0533780 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | # ββ GLM-OCR β Dockerfile (Hugging Face Spaces) ββββββββββββββββββββββββββββ
#
# HF Spaces builds this automatically when you push to your Space repo.
# No local Docker needed β HF handles the build and hosting.
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# Use plain Python slim β no CUDA needed on the free CPU tier,
# and it avoids the old PyTorch 2.2 in the pytorch/pytorch base image
# (GLM-OCR's transformers requires PyTorch >= 2.4).
FROM python:3.11-slim
# ββ System deps ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
RUN apt-get update && apt-get install -y --no-install-recommends \
libgl1 \
libglib2.0-0 \
curl \
&& rm -rf /var/lib/apt/lists/*
# ββ Workdir ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
WORKDIR /app
# ββ Install CPU PyTorch first (must come before requirements.txt so pip
# doesn't pull the CUDA build from PyPI and stays on >=2.4) βββββββββββββ
RUN pip install --no-cache-dir \
"torch>=2.4.0" \
"torchvision>=0.19.0" \
--index-url https://download.pytorch.org/whl/cpu
# ββ Install remaining dependencies βββββββββββββββββββββββββββββββββββββββββ
# pip will see torch/torchvision already satisfy their constraints and skip them
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
# ββ Copy source (flat structure) βββββββββββββββββββββββββββββββββββββββββββ
COPY main.py ocr_engine.py ./
COPY frontend/ ./frontend/
# ββ Expose & run (HF Spaces requires port 7860) ββββββββββββββββββββββββββββ
EXPOSE 7860
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|