Spaces:
Sleeping
Sleeping
| FROM python:3.12-slim | |
| # HF Spaces runs as user 1000 | |
| RUN useradd -m -u 1000 user | |
| WORKDIR /app | |
| # Install system deps | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| gcc libpq-dev curl && \ | |
| rm -rf /var/lib/apt/lists/* | |
| # Copy requirements first (leverages Docker layer cache) | |
| COPY requirements.txt . | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Copy app code | |
| COPY . . | |
| # Create data and logs dirs with correct ownership | |
| RUN mkdir -p data logs && chown -R user:user /app | |
| USER user | |
| # HF Spaces uses port 7860 | |
| EXPOSE 7860 | |
| # Health check | |
| HEALTHCHECK --interval=30s --timeout=10s --start-period=15s --retries=3 \ | |
| CMD curl -f http://localhost:7860/health || exit 1 | |
| CMD ["uvicorn", "app.main:app", \ | |
| "--host", "0.0.0.0", \ | |
| "--port", "7860", \ | |
| "--workers", "1", \ | |
| "--log-level", "info", \ | |
| "--access-log"] | |