FROM python:3.10-slim ENV PYTHONUNBUFFERED=1 ENV NODE_VERSION=20 # ── System deps + Node.js ──────────────────────────────────────────────────── RUN apt-get update && apt-get install -y \ git curl build-essential ca-certificates gnupg \ && mkdir -p /etc/apt/keyrings \ && curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key \ | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \ && echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_${NODE_VERSION}.x nodistro main" \ > /etc/apt/sources.list.d/nodesource.list \ && apt-get update && apt-get install -y nodejs \ && rm -rf /var/lib/apt/lists/* WORKDIR /app # ── Python dependencies (cached layer) ────────────────────────────────────── COPY requirements.txt . RUN pip install --no-cache-dir --upgrade pip \ && pip install --no-cache-dir -r requirements.txt # ── Build React frontend ───────────────────────────────────────────────────── COPY frontend/package*.json ./frontend/ RUN cd frontend && npm install COPY frontend/ ./frontend/ RUN cd frontend && npm run build # ── Copy the rest of the app (backend + db + embeddings) ──────────────────── COPY . . # ── HF Spaces runs as non-root uid 1000 ───────────────────────────────────── RUN useradd -m -u 1000 hfuser \ && chown -R hfuser:hfuser /app USER hfuser EXPOSE 7860 CMD ["python", "app.py"]