# Base image with Python and CUDA for GPU support FROM nvidia/cuda:12.1.1-cudnn8-runtime-ubuntu22.04 # Install system dependencies RUN apt-get update && \ apt-get install -y --no-install-recommends \ python3.10 \ python3-pip \ python3.10-venv \ git \ libgl1 \ libglib2.0-0 && \ rm -rf /var/lib/apt/lists/* # Create and activate virtual environment RUN python3.10 -m venv /opt/venv ENV PATH="/opt/venv/bin:$PATH" # Install Python dependencies first (for better caching) COPY requirements.txt . COPY app.py . COPY qwen_classifier/ ./qwen_classifier/ COPY setup.py . RUN pip install --no-cache-dir -r requirements.txt # Install PyTorch with CUDA support RUN pip install --no-cache-dir \ torch==2.1.2+cu121 \ torchvision==0.16.2+cu121 \ --extra-index-url https://download.pytorch.org/whl/cu121 # Run FastAPI app EXPOSE 7860 CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]