File size: 2,183 Bytes
1605cbb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# ─────────────────────────────────────────────────────────────────────────────
# FALSIFY — live belief-revision copilot
#
# Single-stage image. The frontend is dependency-free static files (no React
# build), so there is NO Node stage — one fewer thing to break in CI. FastAPI
# serves the API, the SSE stream, AND the static UI from one port.
#
# Portable across hosts: binds to $PORT (Render injects it) and falls back to
# 7860 (Hugging Face Spaces' default). Same image runs on both.
# ─────────────────────────────────────────────────────────────────────────────
FROM python:3.11-slim

# Hugging Face Spaces run containers as uid 1000; create that user so writes
# to cache/model dirs don't hit permission errors.
RUN useradd -m -u 1000 user
WORKDIR /home/user/app

# System deps some wheels (lancedb/kuzu/onnxruntime) expect at runtime.
RUN apt-get update && apt-get install -y --no-install-recommends \
        libgomp1 curl \
    && rm -rf /var/lib/apt/lists/*

# Dependencies first for layer caching (Cognee is heavy — cache it across rebuilds).
COPY --chown=user requirements.txt .
RUN pip install --no-cache-dir --upgrade pip && \
    pip install --no-cache-dir -r requirements.txt && \
    chown -R user:user /usr/local/lib/python3.11/site-packages/cognee

# Pre-warm the local fastembed model so the FIRST request isn't a model download.
# Best-effort: never fail the build if the hub is briefly unreachable.
RUN python -c "from fastembed import TextEmbedding; TextEmbedding()" || true

# App code (includes ./static — the built-in frontend).
COPY --chown=user . .

USER user
ENV HOME=/home/user \
    PATH=/home/user/.local/bin:$PATH \
    HF_HOME=/home/user/app/.cache \
    PORT=7860 \
    PYTHONUNBUFFERED=1

EXPOSE 7860

# Shell form so $PORT expands (HF=7860, Render=its injected value).
CMD uvicorn server:app --host 0.0.0.0 --port ${PORT:-7860}