| # Use Python 3.11 slim image | |
| FROM python:3.11-slim | |
| # Set working directory | |
| WORKDIR /app | |
| # Install system dependencies | |
| RUN apt-get update && apt-get install -y \ | |
| gcc \ | |
| curl \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Copy requirements first for caching | |
| COPY requirements.txt . | |
| # Install Python dependencies | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Copy application code | |
| COPY . . | |
| # Create non-root user for security | |
| RUN useradd -m appuser && chown -R appuser /app | |
| USER appuser | |
| # Hugging Face requires apps to run on port 7860 | |
| CMD uvicorn app:app --host 0.0.0.0 --port 7860 | |