# Use official Python image FROM python:3.9-slim # Set the working directory WORKDIR /app # Install system dependencies (needed for compiling some python packages if required) RUN apt-get update && apt-get install -y --no-install-recommends \ build-essential \ && rm -rf /var/lib/apt/lists/* # Copy requirements COPY requirements.txt . # Install Python dependencies RUN pip install --no-cache-dir -r requirements.txt # Copy the rest of the application and set ownership to the non-root user COPY --chown=user:user . . # Hugging Face Spaces require running as a non-root user (UID 1000) RUN useradd -m -u 1000 user USER user ENV HOME=/home/user \ PATH=/home/user/.local/bin:$PATH # Expose the port HF Spaces uses EXPOSE 7860 # Command to run the application CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]