# HF Docker Space image (issue #26). Built remotely by Hugging Face -- no local # Docker needed. Two stages: build the React SPA with Node, then run FastAPI on # a slim Python image that serves both the API and the built SPA on one port. # --- stage 1: build the frontend ------------------------------------------ FROM node:20-slim AS frontend WORKDIR /frontend COPY frontend/package*.json ./ RUN npm ci COPY frontend/ ./ # Same-origin: the SPA calls /api/... relative to wherever it's served. ENV VITE_API_BASE="" RUN npm run build # --- stage 2: python serving runtime -------------------------------------- FROM python:3.11-slim WORKDIR /app COPY requirements-serve.txt . RUN pip install --no-cache-dir -r requirements-serve.txt COPY src/ ./src/ COPY scripts/space_startup.sh ./scripts/space_startup.sh COPY --from=frontend /frontend/dist ./frontend/dist # The mapping/taxonomy engine reads these at request time (the registry CSVs and dependency graph, and # the taxonomy registry doc), so /api/concepts, /api/mapping, the dashboard and the export resolve. The # copyrighted source PDFs under data/taxonomy/sources are excluded (.dockerignore, and the deploy upload). COPY data/taxonomy ./data/taxonomy COPY docs/taxonomy.md ./docs/taxonomy.md ENV PYTHONPATH=/app/src \ ENDOPATH_FRONTEND_DIST=/app/frontend/dist \ ENDOPATH_EMBEDDINGS_DIR=/app/data/images \ HF_HUB_DISABLE_TELEMETRY=1 # HF Spaces route to port 7860 by default. EXPOSE 7860 CMD ["bash", "scripts/space_startup.sh"]