# PhysiX-Live demo Space — CPU-only env + UI on :7860 # # uvicorn _space_app:app # ├─ /reset, /step OpenEnv stateless API # ├─ /interactive/* browser session API + LLM-step # └─ /web/ built React SPA # # No torch / vLLM / GPU here. LLM inference is forwarded to whatever # OpenAI-compatible base URL the browser provides (HF Router, OpenAI, # Ollama, or our sister L4 Space `Pratyush-01/physix-infer`). ############################ # Stage 1: build the SPA ############################ FROM node:20-alpine AS frontend WORKDIR /spa RUN corepack enable COPY frontend/ ./ # Same-origin API fetches at runtime (Space serves both API and UI). ENV VITE_PHYSIX_API_URL="" RUN pnpm install --frozen-lockfile \ && pnpm exec tsc -b \ && pnpm exec vite build --base=/web/ ############################ # Stage 2: runtime ############################ FROM python:3.11-slim AS runtime ENV PYTHONUNBUFFERED=1 \ PIP_NO_CACHE_DIR=1 \ PIP_DISABLE_PIP_VERSION_CHECK=1 \ HOME=/tmp/home \ HF_HOME=/tmp/hf_cache \ XDG_CACHE_HOME=/tmp/xdg-cache \ PORT=7860 \ PHYSIX_HOST=0.0.0.0 \ PHYSIX_CORS_ORIGINS=* RUN apt-get update \ && apt-get install -y --no-install-recommends curl \ && rm -rf /var/lib/apt/lists/* WORKDIR /app # Inference deps only — no torch / unsloth / trl. Training runs on HF Jobs. RUN pip install \ "openenv-core[core]>=0.2.2" \ "numpy>=1.24" \ "scipy>=1.10" \ "sympy>=1.12" \ "fastapi>=0.110" \ "uvicorn[standard]>=0.29" \ "pydantic>=2.5" \ "openai>=1.40" \ "requests>=2.31" COPY pyproject.toml README.md ./ COPY physix ./physix RUN pip install --no-deps -e . COPY --from=frontend /spa/dist /app/static COPY scripts/space_app.py /app/_space_app.py # HF Spaces runs as a non-root UID with no /etc/passwd; pre-create # writable cache dirs so $HOME-based caches work. RUN mkdir -p "$HOME" "$HF_HOME" "$XDG_CACHE_HOME" \ && chmod -R 0777 /tmp /app EXPOSE 7860 HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \ CMD curl -fsS "http://127.0.0.1:${PORT}/health" || exit 1 CMD ["python3", "-m", "uvicorn", "_space_app:app", "--host", "0.0.0.0", "--port", "7860"]