FROM python:3.10-slim # Create a non-root user for security (required for Hugging Face Spaces Dev Mode) RUN useradd -m -u 1000 user # Set working directory WORKDIR /app # Copy requirements file and install dependencies COPY --chown=user ./requirements.txt requirements.txt RUN pip install --no-cache-dir --upgrade pip && \ pip install --no-cache-dir -r requirements.txt # Copy the rest of the application code COPY --chown=user . /app # Switch to non-root user USER user # Set environment variables for Hugging Face Spaces ENV HOME=/home/user \ PATH=/home/user/.local/bin:$PATH \ PYTHONUNBUFFERED=1 # Expose port 7860 (default for Hugging Face Spaces) EXPOSE 7860 # Command to run the application CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]