Spaces:
Running
Running
File size: 2,714 Bytes
8ce332b 0bf6516 8ce332b 0bf6516 8ce332b 0bf6516 8ce332b 0bf6516 8ce332b 0bf6516 8ce332b 0bf6516 8ce332b 0bf6516 8ce332b 0bf6516 8ce332b 0bf6516 8ce332b 0bf6516 8ce332b 0bf6516 8ce332b 0bf6516 8ce332b 0bf6516 8ce332b 0bf6516 8ce332b 0bf6516 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | # βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# CustomerCore β Hugging Face Spaces Dockerfile (Phase 10)
#
# WHY A SEPARATE DOCKERFILE FOR HF SPACES?
# HF Spaces has specific constraints:
# - 2 vCPUs, 16GB RAM on free tier (Zero GPU)
# - No JVM/JDK allowed on the smallest tier (PySpark requires 500MB+ JDK)
# - Container must listen on port 7860 (HF Spaces requirement)
# - No root user (HF runs as user 1000)
# - 50GB ephemeral storage (data is lost on restart β use Supabase for persistence)
#
# This image strips PySpark and uses a lightweight requirements file.
# The API still works: BM25 retrieval, LLM routing, and LangGraph triage all function
# without PySpark. The BronzeβSilver data pipeline is not needed for inference.
#
# HF Spaces deployment:
# 1. Create a new Space at huggingface.co/spaces
# 2. Select "Docker" as the SDK
# 3. Add this file as Dockerfile in the repo root
# 4. Set secrets in Space settings (same values as Doppler)
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
FROM python:3.12-slim-bookworm
LABEL org.opencontainers.image.title="CustomerCore API (HF Spaces)" \
org.opencontainers.image.description="CustomerCore β Lightweight deployment for Hugging Face Spaces" \
org.opencontainers.image.version="1.0.0"
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PYTHONPATH=/app \
APP_ENV=production \
# HF Spaces requires port 7860
PORT=7860
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
&& rm -rf /var/lib/apt/lists/*
# HF Spaces runs as user 1000 β create matching user
RUN useradd -m -u 1000 hfuser
WORKDIR /app
# Use the slim CI requirements file β already Linux-safe (no pywin32, pyspark, etc.)
COPY requirements-ci.txt .
RUN pip install --no-cache-dir \
--extra-index-url https://download.pytorch.org/whl/cpu \
-r requirements-ci.txt
COPY src/ ./src/
COPY pyproject.toml .
RUN mkdir -p logs data \
&& chown -R hfuser:hfuser /app
USER hfuser
HEALTHCHECK --interval=30s --timeout=10s --start-period=20s --retries=3 \
CMD curl -f http://localhost:7860/api/v1/health || exit 1
EXPOSE 7860
# Single worker on HF free tier (2 vCPU)
CMD ["uvicorn", "src.api.main:app", \
"--host", "0.0.0.0", \
"--port", "7860", \
"--workers", "1", \
"--log-level", "warning"]
|