Spaces:
Sleeping
Sleeping
Delete Dockerfile
Browse files- Dockerfile +0 -125
Dockerfile
DELETED
|
@@ -1,125 +0,0 @@
|
|
| 1 |
-
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 2 |
-
# MinerU OCR Service β Hugging Face Docker Space (CPU / pipeline backend)
|
| 3 |
-
# Optimized for FREE tier: 2 vCPU Β· 16 GB RAM Β· 50 GB Disk Β· No GPU
|
| 4 |
-
#
|
| 5 |
-
# ββ Root cause of previous failures ββββββββββββββββββββββββββββββββββββββββββ
|
| 6 |
-
#
|
| 7 |
-
# Failure 1: No module named 'cv2'
|
| 8 |
-
# Cause: magic-pdf[full-cpu] may pull in opencv-python (X11 build) instead
|
| 9 |
-
# of headless; removed X11 libs caused dlopen failure.
|
| 10 |
-
# Fix: Explicitly install opencv-python-headless in Layer 1 BEFORE
|
| 11 |
-
# magic-pdf, so pip considers cv2 already satisfied.
|
| 12 |
-
#
|
| 13 |
-
# Failure 2: stat: path should be string ... not list
|
| 14 |
-
# Cause: read_local_images([path]) β list passed where string expected.
|
| 15 |
-
# Fix: FileBasedDataReader + ImageDataset in main.py (code fix, not here).
|
| 16 |
-
#
|
| 17 |
-
# Failure 3: No module named 'ultralytics'
|
| 18 |
-
# Cause: ultralytics β torch β no CPU torch wheel on PyPI. pip's resolver
|
| 19 |
-
# saw no satisfiable torch, skipped ultralytics entirely. Since
|
| 20 |
-
# doclayout_yolo requires ultralytics, layout detection crashed.
|
| 21 |
-
# Fix: Install torch/torchvision CPU from the official PyTorch CPU index
|
| 22 |
-
# in a dedicated layer BEFORE magic-pdf, then list all OCR runtime
|
| 23 |
-
# deps explicitly so pip cannot skip them.
|
| 24 |
-
#
|
| 25 |
-
# ββ Pip layer strategy ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 26 |
-
# Layer 1 β small/fast packages + opencv-headless
|
| 27 |
-
# Layer 2 β torch CPU + torchvision CPU (PyTorch official CPU wheel index)
|
| 28 |
-
# Own layer: large (~500 MB), slow, cached on rebuild.
|
| 29 |
-
# Must be BEFORE magic-pdf so torch is pre-satisfied.
|
| 30 |
-
# Layer 3 β magic-pdf[full-cpu] + ALL explicit OCR runtime deps
|
| 31 |
-
# Explicit listing prevents silent skip of transitive deps.
|
| 32 |
-
#
|
| 33 |
-
# ββ System packages βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 34 |
-
# Removed: libreoffice (1.5 GB, DOCX/PPTX/XLSX support dropped for MVP)
|
| 35 |
-
# libsm6 libxext6 libxrender-dev (X11 display stubs, not needed headless)
|
| 36 |
-
# libmagic1 (python-magic not used)
|
| 37 |
-
# wget curl (runtime tools, not needed in container)
|
| 38 |
-
# Kept: libgl1 β OpenCV requires libGL.so.1
|
| 39 |
-
# libglib2.0-0 β GLib, required by OpenCV and C extensions
|
| 40 |
-
# libgomp1 β OpenMP, required by ONNX Runtime and YOLO
|
| 41 |
-
# poppler-utils β pdfinfo / pdftoppm for MinerU PDF pre-processing
|
| 42 |
-
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 43 |
-
|
| 44 |
-
FROM python:3.10-slim
|
| 45 |
-
|
| 46 |
-
ENV PYTHONUNBUFFERED=1
|
| 47 |
-
ENV PYTHONDONTWRITEBYTECODE=1
|
| 48 |
-
ENV PORT=7860
|
| 49 |
-
ENV MINERU_DEVICE_MODE=cpu
|
| 50 |
-
ENV MINERU_BACKEND=pipeline
|
| 51 |
-
|
| 52 |
-
# ββ System dependencies βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 53 |
-
RUN apt-get update \
|
| 54 |
-
&& apt-get install -y --no-install-recommends \
|
| 55 |
-
libgl1 \
|
| 56 |
-
libglib2.0-0 \
|
| 57 |
-
libgomp1 \
|
| 58 |
-
poppler-utils \
|
| 59 |
-
&& rm -rf /var/lib/apt/lists/*
|
| 60 |
-
|
| 61 |
-
WORKDIR /app
|
| 62 |
-
|
| 63 |
-
# ββ Layer 1: small packages + opencv-headless βββββββββββββββββββββββββββββββββ
|
| 64 |
-
RUN pip install --no-cache-dir --timeout 300 \
|
| 65 |
-
"fastapi>=0.115.0" \
|
| 66 |
-
"uvicorn[standard]>=0.32.0" \
|
| 67 |
-
"python-multipart>=0.0.12" \
|
| 68 |
-
"Pillow>=10.0.0" \
|
| 69 |
-
"pillow-heif>=0.18.0" \
|
| 70 |
-
"huggingface_hub>=0.25.0" \
|
| 71 |
-
"opencv-python-headless>=4.8.0"
|
| 72 |
-
|
| 73 |
-
# ββ Layer 2: torch CPU + torchvision CPU ββββββββββββββββββββββββββββββββββββββ
|
| 74 |
-
# MUST use --index-url (not --extra-index-url) to prefer the CPU-only wheel.
|
| 75 |
-
# Without this layer, pip finds no CPU-compatible torch on PyPI and silently
|
| 76 |
-
# skips ultralytics, doclayout_yolo, and anything else that depends on torch.
|
| 77 |
-
RUN pip install --no-cache-dir --timeout 600 \
|
| 78 |
-
--index-url https://download.pytorch.org/whl/cpu \
|
| 79 |
-
"torch>=2.0.0" \
|
| 80 |
-
"torchvision>=0.15.0"
|
| 81 |
-
|
| 82 |
-
# ββ Layer 3: magic-pdf + ALL explicit OCR runtime dependencies ββββββββββββββββ
|
| 83 |
-
# Every package listed here is a confirmed runtime requirement of doc_analyze:
|
| 84 |
-
#
|
| 85 |
-
# magic-pdf[full-cpu] β MinerU core + extras
|
| 86 |
-
# doclayout-yolo β layout detection model wrapper (uses ultralytics)
|
| 87 |
-
# ultralytics β YOLO inference (doclayout_yolo runtime)
|
| 88 |
-
# onnxruntime β ONNX inference for MFD / table models
|
| 89 |
-
# paddlepaddle β PaddleOCR backend (CPU; from myhloli index)
|
| 90 |
-
# paddleocr β OCR engine (text extraction)
|
| 91 |
-
# rapid-table β table structure reconstruction
|
| 92 |
-
# shapely β geometry ops used by paddleocr
|
| 93 |
-
# pyclipper β polygon clipping used by paddleocr
|
| 94 |
-
# scipy β scientific computing used by layout/OCR models
|
| 95 |
-
RUN pip install --no-cache-dir --timeout 600 \
|
| 96 |
-
--extra-index-url https://myhloli.github.io/wheels/ \
|
| 97 |
-
"magic-pdf[full-cpu]==1.3.12" \
|
| 98 |
-
"doclayout-yolo>=0.0.2" \
|
| 99 |
-
"ultralytics>=8.0.0" \
|
| 100 |
-
"onnxruntime>=1.17.0" \
|
| 101 |
-
"paddleocr>=2.7.0" \
|
| 102 |
-
"rapid-table>=0.2.0" \
|
| 103 |
-
"shapely>=2.0.0" \
|
| 104 |
-
"pyclipper>=1.3.0" \
|
| 105 |
-
"scipy>=1.11.0"
|
| 106 |
-
|
| 107 |
-
# ββ Application code ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 108 |
-
COPY download_models.py .
|
| 109 |
-
COPY validate.py .
|
| 110 |
-
COPY main.py .
|
| 111 |
-
COPY entrypoint.sh .
|
| 112 |
-
RUN chmod +x entrypoint.sh
|
| 113 |
-
|
| 114 |
-
# ββ Download models at build time βββββββββββββββββββββββββββββββββββββββββββββ
|
| 115 |
-
# Baked into image = zero cold-start download delay.
|
| 116 |
-
# Skip-if-exists in download_models.py = Docker layer-cache reuse on
|
| 117 |
-
# code-only rebuilds (models already present, download skipped).
|
| 118 |
-
RUN python download_models.py
|
| 119 |
-
|
| 120 |
-
# Persist config; entrypoint.sh restores it if /root is wiped on restart.
|
| 121 |
-
RUN mkdir -p /app/config && cp /root/magic-pdf.json /app/config/magic-pdf.json
|
| 122 |
-
|
| 123 |
-
# ββ Runtime βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 124 |
-
EXPOSE 7860
|
| 125 |
-
ENTRYPOINT ["/app/entrypoint.sh"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|