chanmin0723/obcon-scada
0
OBCon SCADA — HuggingFace Space (Docker)
Node.js Express SCADA viewer for cathodic protection devices. This Space wraps the full backend (HTTP worker + MariaDB + optional Redis) into a single Docker container exposed on port 7860.
Architecture (single container)
HF Space (Docker SDK, port 7860)
└── entrypoint.sh
├── 1. mariadb (127.0.0.1:3306)
│ ├── creates obcondb + scada user from $OBCON_DB_PASS
│ └── loads /seed/*.sql on first cold boot
├── 2. redis (127.0.0.1:6379) — optional, off by default
└── 3. node bin/scada.js --conf config_scada_hf.js
listens on 0.0.0.0:7860Required HF Space Secrets
Set these in Settings → Variables and secrets:
All other env vars have sensible defaults in config_scada_hf.js.
Cold-boot constraints
- Ephemeral filesystem. MariaDB datadir at
/var/lib/mysqlis wiped on each container restart on the free tier. The container re-applies/seed/*.sqlautomatically on every cold boot, so the demo state stays reproducible. Persistent runtime data requires HF Persistent Storage (paid). - Sleep after inactivity (free tier). First request after sleep ≈ 5–10 s for MariaDB boot + schema seed.
- Single port. TCP modbus (502) and UDP listeners are disabled — devices cannot push data inbound to a Space. Workers are set to
HTTP=1, TCP=0, UDP=0, MODBUS=0, PROXY=0.
Local test
docker build -t obcon-hf .
docker run --rm -p 7860:7860 \
-e OBCON_DB_PASS=scada \
obcon-hf
# → http://localhost:7860/scada/Files
Dockerfile— base image + apt deps + npm install.entrypoint.sh— boots services in order.config_scada_hf.js— env-driven config; no secrets in source.seed/—01_schema.sql(schema only) +02_bootstrap.sql(one admin user) + optional03_sample.sql(anonymized sample data). Generate locally withbash scripts/build_seed.shbeforedocker build.app/— copy of the obcon Node app (no logs/sessions/files/.git).scripts/build_seed.sh— schema + bootstrap admin SQL generator.scripts/anonymize_sample.py— optional anonymized sample data extractor.
See DEPLOY.md for the full push procedure and SECRETS.md for the credential inventory.
