Spaces:
Sleeping
Sleeping
| FROM ubuntu:24.04 | |
| ENV DEBIAN_FRONTEND=noninteractive | |
| # 1. Install Python 3.10 + system deps required by Docling (libglib2.0-0, libgl1) | |
| RUN apt-get update && apt-get install -y \ | |
| software-properties-common \ | |
| curl \ | |
| && add-apt-repository ppa:deadsnakes/ppa \ | |
| && apt-get update && apt-get install -y \ | |
| python3.10 \ | |
| python3.10-dev \ | |
| python3.10-distutils \ | |
| build-essential \ | |
| libmagic-dev \ | |
| libglib2.0-0 \ | |
| libgl1 \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # 2. Install pip for Python 3.10 | |
| RUN curl -sS https://bootstrap.pypa.io/get-pip.py | python3.10 | |
| RUN python3.10 -m pip install --no-cache-dir --upgrade pip | |
| # 3. Install Python requirements | |
| WORKDIR /app | |
| COPY requirements.txt /app/requirements.txt | |
| RUN python3.10 -m pip install --no-cache-dir -r requirements.txt | |
| # 4. FIX: RapidOCR downloads weights at runtime into the system python dir. | |
| # By making the rapidocr directory globally writable, the non-root 'ubuntu' | |
| # user can successfully save the weights there on the first request. | |
| RUN mkdir -p /usr/local/lib/python3.10/dist-packages/rapidocr/models && \ | |
| chmod -R 777 /usr/local/lib/python3.10/dist-packages/rapidocr | |
| # 5. Ubuntu 24.04 already has UID 1000 as user "ubuntu" — use it directly | |
| RUN chown -R ubuntu:ubuntu /app | |
| USER ubuntu | |
| ENV HOME=/home/ubuntu \ | |
| PATH=/home/ubuntu/.local/bin:$PATH | |
| # 6. Copy application code | |
| COPY --chown=ubuntu . /app | |
| # 7. Block HF persistent user cache interference | |
| ENV PYTHONNOUSERSITE=1 | |
| EXPOSE 7860 | |
| CMD ["python3.10", "-m", "uvicorn", "app.app:app", "--host", "0.0.0.0", "--port", "7860"] |