FROM python:3.11-slim # Set up a new user named "user" with UID 1000 to avoid running as root RUN useradd -m -u 1000 user USER user ENV HOME=/home/user \ PATH=/home/user/.local/bin:$PATH WORKDIR $HOME/app # Copy requirements and install COPY --chown=user requirements.txt $HOME/app/requirements.txt RUN pip install --no-cache-dir --upgrade -r requirements.txt # Copy the rest of the application files COPY --chown=user . $HOME/app # Expose the default port Hugging Face Spaces expects (7860) EXPOSE 7860 # Run FastAPI CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]