Spaces:
Sleeping

Ajayyy00 Claude Sonnet 4.6 commited on
Commit
0cd6bdd
Β·
1 Parent(s): 1080341

Split architecture: Trainer=backend, Demo=dashboard

Browse files

Dockerfile
- Replaces hard-coded uvicorn CMD with /bin/sh /app/start.sh
- Sets ownership correctly before switching to non-root user

start.sh (new)
- Reads BACKEND_URL env var β†’ writes it into dashboard/js/config.js
- Reads SERVE_DASHBOARD_ONLY env var:
0 / unset β†’ full stack via dashboard_server.py (Trainer Space)
1 β†’ static-only via serve_demo.py (Demo Space)

serve_demo.py (new)
- Minimal FastAPI + StaticFiles server for the Demo space
- Serves dashboard/ on port 7860 with CORS enabled

dashboard/js/config.js (new)
- Sets window.CYBERSOC_BACKEND_URL = '' by default
- Overwritten at container startup by start.sh when BACKEND_URL is set

dashboard/js/api.js
- Reads window.CYBERSOC_BACKEND_URL set by config.js
- _wsUrl() and _httpBase() use the override URL when set,
fall back to same-origin auto-detection when empty

dashboard/index.html
- Loads js/config.js before api.js so the override is available

HF Space setup:
CyberSOC-trainer β†’ no extra env vars (full backend mode)
Demo β†’ SERVE_DASHBOARD_ONLY=1
BACKEND_URL=https://ajay00747-cybersoc-trainer.hf.space

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

6 files changed +122 -10
Files changed (6)
Dockerfile+14-10
dashboard/index.html+1
dashboard/js/api.js+15
dashboard/js/config.jsAdded+12
serve_demo.pyAdded+43
start.shAdded+37