CoolFace
Apppublic

chanmin0723/obcon-scada

sourceHugging Faceupdated 25d agoView on Hugging Face
0likes
App README

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:7860

Required HF Space Secrets

Set these in Settings → Variables and secrets:

NameRequiredNote
OBCON_DB_PASSMariaDB password for the scada user (any strong string)
OBCON_ENCRYPT_KEYrecommendedSession/JWT key. If empty, sessions reset on every restart.
OBCON_KAKAO_APPKEYoptionalKakao Maps JS appkey (registered for this HF domain). If empty the Leaflet+OSM fallback is used.
OBCON_THINGPLUG_*optionalOnly if you actually use ThingPlug.

All other env vars have sensible defaults in config_scada_hf.js.

Cold-boot constraints

  • Ephemeral filesystem. MariaDB datadir at /var/lib/mysql is wiped on each container restart on the free tier. The container re-applies /seed/*.sql automatically 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

bash
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) + optional 03_sample.sql (anonymized sample data). Generate locally with bash scripts/build_seed.sh before docker 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.