# Use Python 3.10 slim image FROM python:3.11-slim # Set the working directory WORKDIR /app # Create a non-root user (Mandatory for Hugging Face Spaces) RUN useradd -m -u 1000 user USER user ENV HOME=/home/user \ PATH=/home/user/.local/bin:$PATH # Set working directory to the user's home WORKDIR $HOME/app # Copy requirements first to leverage Docker cache COPY --chown=user:user requirements.txt . # Install dependencies RUN pip install --no-cache-dir --upgrade pip && \ pip install --no-cache-dir -r requirements.txt # Copy the rest of the application COPY --chown=user:user . . # Expose the port Hugging Face expects EXPOSE 7860 # Command to run the application CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]