Spaces:
Sleeping
Sleeping
File size: 1,436 Bytes
250666a 09213ce 250666a | 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 | # Amana — single-container deploy for Hugging Face Spaces (sdk: docker).
# Stage 1 builds the React SPA; stage 2 runs FastAPI, which serves both /api and the built SPA.
# ---- Stage 1: build the React frontend ----
FROM node:20-slim AS frontend
WORKDIR /app/frontend
COPY frontend/package.json frontend/package-lock.json* ./
RUN npm ci
COPY frontend/ ./
RUN npm run build
# ---- Stage 2: Python runtime ----
FROM python:3.11-slim
WORKDIR /app
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
# App code + data, then build the Chroma index at image-build time (local embeddings, no API key,
# no spend) so the Space starts with no ingestion step. This also caches the embedding model layer.
COPY src/ ./src/
COPY scripts/ ./scripts/
COPY data/ ./data/
COPY api.py ./
RUN python -m scripts.build_index
# The built SPA from stage 1.
COPY --from=frontend /app/frontend/dist ./frontend/dist
# Make data writable for the non-root user HF Spaces runs as (audit log + Chroma sqlite).
RUN chmod -R a+rwX /app/data
ENV LLM_PROVIDER=anthropic
# Public-demo spend cap: lock /api/triage to Anthropic + no cache-bypass so a public Space can't be
# used as a billing faucet (max spend = the 18 fixed campaigns once each per restart). See api.py.
ENV PUBLIC_DEMO=1
EXPOSE 7860
# Shell form so $PORT (if the platform injects one) is honoured; defaults to 7860.
CMD uvicorn api:app --host 0.0.0.0 --port ${PORT:-7860}
|