FROM python:3.10-slim WORKDIR /app # Install system dependencies RUN apt-get update && apt-get install -y \ libgl1 \ libglib2.0-0 \ libsm6 \ libxext6 \ libxrender1 \ libgomp1 \ wget \ && rm -rf /var/lib/apt/lists/* # Copy requirements first for better caching COPY requirements.txt . # Install base dependencies RUN pip install --no-cache-dir -r requirements.txt # Install CPU-only PyTorch (from official source) RUN pip install --no-cache-dir torch==2.0.1 --index-url https://download.pytorch.org/whl/cpu RUN pip install --no-cache-dir torchvision==0.15.2 --index-url https://download.pytorch.org/whl/cpu # Install Hugging Face ecosystem with compatible versions RUN pip install --no-cache-dir transformers==4.30.2 RUN pip install --no-cache-dir sentence-transformers==2.2.2 RUN pip install --no-cache-dir accelerate==0.21.0 RUN pip install --no-cache-dir tokenizers==0.13.3 RUN pip install --no-cache-dir huggingface-hub==0.16.4 # Install remaining packages RUN pip install --no-cache-dir scikit-image==0.21.0 scipy==1.10.1 httpx==0.24.1 aiofiles==23.2.1 COPY . . EXPOSE 7860 CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]