# Modern NVIDIA base image with CUDA 12.9 and Ubuntu 24.04 LTS FROM nvidia/cuda:12.9.1-runtime-ubuntu24.04 # Avoid interactive errors ENV DEBIAN_FRONTEND=noninteractive # System packages RUN apt-get update && apt-get install -y \ python3 \ python3-pip \ git \ && rm -rf /var/lib/apt/lists/* # Make python3 the default python RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 1 # Working directory WORKDIR /app # Copy requirements first (to enable Docker cache) COPY docker/requirements.txt /app/requirements.txt # Install PyTorch with CUDA support first (separate to use correct index URL) RUN pip install --no-cache-dir torch==2.9.1 --index-url https://download.pytorch.org/whl/cu129 --break-system-packages # Install remaining dependencies RUN pip install --no-cache-dir -r requirements.txt --break-system-packages # Copy application code COPY src/app.py /app/app.py COPY model /app/model # Uvicorn exposed port EXPOSE 7860 # Optimize Python for container ENV PYTHONUNBUFFERED=1 ENV TRANSFORMERS_NO_ADVISORY_WARNINGS=1 CMD ["python", "app.py"]