# HuggingFace Spaces variant — port 7860, debug mode, Supabase Postgres FROM python:3.12-slim WORKDIR /app # Install system deps (curl for healthcheck, git required by HF Spaces builder) RUN apt-get update && apt-get install -y --no-install-recommends curl git \ && rm -rf /var/lib/apt/lists/* # Install all deps in separate layers (avoids HF builder timeout) RUN pip install --no-cache-dir firebase-admin litellm RUN pip install --no-cache-dir cryptography PyNaCl "bcrypt<4.1" RUN pip install --no-cache-dir "fastapi>=0.115.0" "uvicorn[standard]>=0.30.0" "sqlalchemy[asyncio]>=2.0.30" RUN pip install --no-cache-dir asyncpg alembic "pydantic[email]>=2.9.0" pydantic-settings RUN pip install --no-cache-dir "passlib[bcrypt]" "python-jose[cryptography]" httpx python-multipart RUN pip install --no-cache-dir "fastapi-mcp>=0.1.0" "mcp>=1.0.0" "stripe>=8.0.0" RUN pip install --no-cache-dir "pgvector>=0.3.0" "croniter>=2.0.0" # Create non-root user (HF Spaces runs as user 1000) RUN useradd -m -u 1000 appuser # Copy application code (run directly from /app, no package install needed) COPY src/ src/ COPY alembic/ alembic/ COPY alembic.ini . # Switch to non-root user USER appuser # HF Spaces uses port 7860 by default ENV PORT=7860 ENV DEBUG=true EXPOSE ${PORT} HEALTHCHECK --interval=30s --timeout=5s --retries=3 \ CMD curl -f http://localhost:${PORT}/health || exit 1 CMD exec uvicorn src.main:app --host 0.0.0.0 --port ${PORT} --workers 1