Spaces:
Sleeping
Sleeping
| ### Dockerfile for FastAPI app | |
| FROM python:3.12-slim | |
| # Environment | |
| ENV PYTHONUNBUFFERED=1 \ | |
| PYTHONDONTWRITEBYTECODE=1 \ | |
| PIP_NO_CACHE_DIR=off \ | |
| PATH="/root/.local/bin:$PATH" | |
| WORKDIR /app | |
| # Install system deps that some packages may require at build time | |
| RUN apt-get update \ | |
| && apt-get install -y --no-install-recommends build-essential libpq-dev git \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Install Python deps | |
| COPY requirements.txt ./ | |
| RUN pip install --upgrade pip setuptools wheel \ | |
| && pip install --no-cache-dir -r requirements.txt | |
| # Copy source | |
| COPY . . | |
| # Use unprivileged user | |
| RUN useradd -m appuser && chown -R appuser /app | |
| USER appuser | |
| EXPOSE 5001 | |
| # Simple healthcheck (checks docs page) | |
| #HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \ | |
| # CMD curl -f http://localhost:${PORT:-5001}/docs || exit 1 | |
| # Default command - respects platform provided PORT env var (e.g., Hugging Face Spaces) | |
| CMD ["sh", "-c", "uvicorn app.main:app --host 0.0.0.0 --port ${PORT:-7860} --workers 1"] | |