# Use a slim official Python image FROM python:3.12-slim # Hugging Face Spaces runs on port 7860 EXPOSE 7860 # Create a non-root user for security RUN useradd -m -u 1000 appuser WORKDIR /app # Copy dependency list first (better layer caching) COPY requirements.txt . # Install dependencies RUN pip install --no-cache-dir -r requirements.txt # Copy the rest of the application files COPY . . # Set correct ownership RUN chown -R appuser:appuser /app USER appuser # Start the FastAPI app via Uvicorn on port 7860 CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]