FROM python:3.11-slim # Create non-root user (HF Spaces runs with user ID 1000) RUN useradd -m -u 1000 user USER user ENV HOME=/home/user \ PATH=/home/user/.local/bin:$PATH WORKDIR /app # Install dependencies COPY --chown=user server/requirements.txt . RUN pip install --no-cache-dir --user -r requirements.txt # Copy all source code COPY --chown=user . . # HF Spaces uses port 7860 by default ENV PORT=7860 EXPOSE 7860 # Run the FastAPI server CMD ["python", "-m", "uvicorn", "server.app:app", "--host", "0.0.0.0", "--port", "7860"]