chipling commited on
Commit
2fd0c28
·
verified ·
1 Parent(s): 6a288d9

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +27 -11
Dockerfile CHANGED
@@ -1,16 +1,32 @@
1
- # Use the official lightweight CPU-only image from Docling
2
- FROM quay.io/docling-project/docling-serve-cpu:latest
3
 
4
- # Set environment variables for Hugging Face Spaces
5
- ENV HOST=0.0.0.0
6
- ENV PORT=7860
7
- ENV DOCLING_SERVE_ENABLE_UI=1
 
8
 
9
- # Pre-download the SmolDocling model to speed up startup (optional but recommended)
10
- # This ensures the 256M model is ready in the container cache
11
- RUN python3 -c "from docling.document_converter import DocumentConverter; DocumentConverter()"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
 
13
  EXPOSE 7860
14
 
15
- # Start the server
16
- CMD ["docling-serve", "run", "--host", "0.0.0.0", "--port", "7860"]
 
1
+ # Use a Python base with high compatibility
2
+ FROM python:3.10-slim
3
 
4
+ # Install system dependencies for OCR and Image processing
5
+ RUN apt-get update && apt-get install -y \
6
+ libgl1-mesa-glx \
7
+ libglib2.0-0 \
8
+ && rm -rf /var/lib/apt/lists/*
9
 
10
+ WORKDIR /app
11
+
12
+ # Install GLM-OCR and required inference engines
13
+ RUN pip install --no-cache-dir \
14
+ torch --index-url https://download.pytorch.org/whl/cpu \
15
+ transformers \
16
+ accelerate \
17
+ einops \
18
+ pillow \
19
+ fastapi \
20
+ uvicorn \
21
+ python-multipart
22
+
23
+ # Script to pre-load the model (0.9B is ~1.8GB on disk)
24
+ RUN python3 -c "from transformers import AutoModelForCausalLM, AutoTokenizer; \
25
+ AutoModelForCausalLM.from_pretrained('THUDM/glm-4v-9b', trust_remote_code=True)"
26
+
27
+ # Create a simple FastAPI app wrapper
28
+ COPY app.py .
29
 
30
  EXPOSE 7860
31
 
32
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]