FROM pytorch/pytorch:2.1.2-cuda12.1-cudnn8-runtime USER root # Install git for huggingface_hub if needed RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/* # Create non-root user RUN useradd -m -u 1000 user USER user # Set env ENV HOME=/home/user \ PATH=/home/user/.local/bin:$PATH WORKDIR $HOME/app # Dependencies COPY --chown=user requirements.txt . RUN pip install --no-cache-dir --upgrade pip && \ pip install --no-cache-dir -r requirements.txt # Copy source COPY --chown=user . . # Run FastAPI with Uvicorn internal CMD ["python", "app.py"]