Spaces:
Sleeping
Sleeping
| # Use Python 3.11 (Newer, fresher environment to avoid 3.10 caches) | |
| FROM python:3.11-slim-bookworm | |
| # 1. Install system dependencies (git is required for the install below) | |
| RUN apt-get update && apt-get install -y \ | |
| git \ | |
| libgl1 \ | |
| libglib2.0-0 \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # 2. Setup User | |
| RUN useradd -m -u 1000 user | |
| RUN mkdir -p /app && chown user:user /app | |
| USER user | |
| ENV PATH="/home/user/.local/bin:$PATH" | |
| WORKDIR /app | |
| # 3. FORCE INSTALL TORCH CPU (Saves massive space & RAM) | |
| RUN pip install --no-cache-dir torch torchvision --index-url https://download.pytorch.org/whl/cpu | |
| # 4. FORCE INSTALL TRANSFORMERS (The Fix) | |
| # We install directly to ensure we get the version that supports Florence-2 | |
| RUN pip install --no-cache-dir --upgrade transformers>=4.46.0 | |
| # 5. Install other dependencies | |
| COPY --chown=user ./requirements.txt requirements.txt | |
| RUN pip install --no-cache-dir --upgrade -r requirements.txt | |
| # 6. Copy Application | |
| COPY --chown=user . /app | |
| # 7. Start | |
| CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] |