# Use an official Python runtime as a parent image FROM python:3.10-slim # Set environment variables ENV PYTHONUNBUFFERED=1 \ PYTHONDONTWRITEBYTECODE=1 \ HOME=/home/user \ PATH=/home/user/.local/bin:$PATH # Create a non-root user RUN useradd -m -u 1000 user USER user WORKDIR $HOME/app # Install dependencies COPY --chown=user requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Copy the rest of the application code COPY --chown=user . . # Expose the port (Hugging Face Spaces use 7860) EXPOSE 7860 # Command to run the application CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]