| # Use an official Python runtime | |
| FROM python:3.10-slim | |
| # Set up a new user named "user" with user ID 1000 | |
| # (Required for Hugging Face Spaces to prevent permission errors) | |
| RUN useradd -m -u 1000 user | |
| USER user | |
| # Set environmental variables | |
| ENV PATH="/home/user/.local/bin:$PATH" | |
| WORKDIR /home/user/app | |
| # Copy requirements and install | |
| COPY --chown=user requirements.txt . | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Copy your backend code | |
| COPY --chown=user . . | |
| # Hugging Face Spaces route web traffic to port 7860 | |
| EXPOSE 7860 | |
| # Start the FastAPI app on port 7860 | |
| CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"] |