Spaces:
Sleeping
Sleeping
| # ββ 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"] | |