| FROM python:3.9-slim | |
| WORKDIR /app | |
| # Install dependencies | |
| COPY requirements.txt . | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Copy application code | |
| COPY . . | |
| # Create a non-root user for security (recommended for HF Spaces) | |
| RUN useradd -m -u 1000 user | |
| USER user | |
| # Set environment variables | |
| ENV HOME=/home/user \ | |
| PATH=/home/user/.local/bin:$PATH \ | |
| PYTHONUNBUFFERED=1 | |
| # Expose port 7860 | |
| EXPOSE 7860 | |
| # Start the application using Gunicorn | |
| CMD ["gunicorn", "-b", "0.0.0.0:7860", "app:app"] | |