| # Use Python 3.9 base image | |
| FROM python:3.9-slim | |
| # Set working directory | |
| WORKDIR /app | |
| # Copy requirements and install dependencies | |
| COPY requirements.txt . | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Create a non-root user (Required by HF Spaces) | |
| RUN useradd -m -u 1000 user | |
| USER user | |
| ENV HOME=/home/user \ | |
| PATH=/home/user/.local/bin:$PATH | |
| # Copy the rest of the application code and model files | |
| COPY --chown=user . /app | |
| # Expose port 7860 (Standard for HF Spaces) | |
| EXPOSE 7860 | |
| # Start command | |
| CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] |