Spaces:
Paused
Paused
Initial Einswarm Node-RED Docker Space (nginx:7860, adminAuth, BMC async)
Browse files- .dockerignore +5 -0
- ANLEITUNG.md +49 -0
- Dockerfile +50 -0
- README.md +50 -5
- assets/einswarm-logo.png +0 -0
- bmc-loader.js +30 -0
- einswarm-editor.css +64 -0
- entrypoint.sh +73 -0
- nginx.conf +67 -0
- settings.js +93 -0
.dockerignore
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.git
|
| 2 |
+
*.md
|
| 3 |
+
!README.md
|
| 4 |
+
!ANLEITUNG.md
|
| 5 |
+
static
|
ANLEITUNG.md
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Einswarm Node-RED — Betriebsanleitung
|
| 2 |
+
|
| 3 |
+
**Space:** https://huggingface.co/spaces/2Btainment/node-red
|
| 4 |
+
**App (neuer Tab):** https://2btainment-node-red.hf.space
|
| 5 |
+
**Zeitzone:** Europe/Berlin
|
| 6 |
+
|
| 7 |
+
---
|
| 8 |
+
|
| 9 |
+
## 1. Zugang
|
| 10 |
+
|
| 11 |
+
- Space ist **privat** (HF-Gate).
|
| 12 |
+
- Direct-URL im **neuen Tab** öffnen, bei Hugging Face eingeloggt.
|
| 13 |
+
- nginx entfernt `X-Frame-Options` / CORP und setzt `frame-ancestors` für huggingface.co.
|
| 14 |
+
|
| 15 |
+
## 2. Login (Admin)
|
| 16 |
+
|
| 17 |
+
Secrets (Settings → Variables and secrets):
|
| 18 |
+
|
| 19 |
+
| Secret | Bedeutung |
|
| 20 |
+
|--------|-----------|
|
| 21 |
+
| `NODE_RED_ADMIN_USER` | Benutzer (Standard: `admin`) |
|
| 22 |
+
| `NODE_RED_ADMIN_PASSWORD` | Passwort — wird beim Start gehasht |
|
| 23 |
+
| `NODE_RED_CREDENTIAL_SECRET` | Schlüssel für Flow-Credentials — **nicht ändern** |
|
| 24 |
+
|
| 25 |
+
1. https://2btainment-node-red.hf.space öffnen
|
| 26 |
+
2. Mit Admin-User/Passwort anmelden
|
| 27 |
+
3. Flows bauen → **Deploy**
|
| 28 |
+
|
| 29 |
+
## 3. Persistenz
|
| 30 |
+
|
| 31 |
+
- `/data` wenn beschreibbar: Flows + Settings
|
| 32 |
+
- Ohne Volume: Daten **ephemeral** bei Rebuild/Sleep
|
| 33 |
+
- Regelmäßig **Export** (Menü → Export)
|
| 34 |
+
|
| 35 |
+
## 4. Einswarm-UI
|
| 36 |
+
|
| 37 |
+
Schwarz/Gold-Theme, Logo im Header, Buy-Me-a-Coffee (async nach Editor-Mount).
|
| 38 |
+
|
| 39 |
+
## 5. Webhooks / HTTP-in
|
| 40 |
+
|
| 41 |
+
HTTP-in Nodes lauschen unter der Direct-URL. CORS ist für HF-Origins geöffnet.
|
| 42 |
+
|
| 43 |
+
## 6. Troubleshooting
|
| 44 |
+
|
| 45 |
+
| Symptom | Aktion |
|
| 46 |
+
|---------|--------|
|
| 47 |
+
| `ERR_BLOCKED_BY_RESPONSE` | Direct-URL nutzen; nginx sollte XFO strippen |
|
| 48 |
+
| Login schlägt fehl | Secret `NODE_RED_ADMIN_PASSWORD` prüfen, Space neu starten |
|
| 49 |
+
| Flows weg nach Restart | Export/Import; Volume oder Backup |
|
Dockerfile
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Einswarm Node-RED — Hugging Face Docker Space (cpu-basic)
|
| 2 |
+
# nginx :7860 → Node-RED :1880; strips X-Frame-Options / CORP for HF embed
|
| 3 |
+
FROM nodered/node-red:latest
|
| 4 |
+
|
| 5 |
+
USER root
|
| 6 |
+
|
| 7 |
+
RUN set -eux; \
|
| 8 |
+
if command -v apk >/dev/null 2>&1; then \
|
| 9 |
+
apk add --no-cache nginx tini curl bash openssl; \
|
| 10 |
+
else \
|
| 11 |
+
apt-get update && apt-get install -y --no-install-recommends nginx tini curl bash openssl ca-certificates \
|
| 12 |
+
&& rm -rf /var/lib/apt/lists/*; \
|
| 13 |
+
fi; \
|
| 14 |
+
mkdir -p \
|
| 15 |
+
/data \
|
| 16 |
+
/einswarm \
|
| 17 |
+
/tmp/nginx_client_body \
|
| 18 |
+
/tmp/nginx_proxy \
|
| 19 |
+
/tmp/nginx_fastcgi \
|
| 20 |
+
/tmp/nginx_uwsgi \
|
| 21 |
+
/tmp/nginx_scgi \
|
| 22 |
+
/var/log/nginx \
|
| 23 |
+
/var/lib/nginx/tmp \
|
| 24 |
+
/run/nginx; \
|
| 25 |
+
chown -R node-red:root /data /einswarm /tmp/nginx_client_body /tmp/nginx_proxy /tmp/nginx_fastcgi /tmp/nginx_uwsgi /tmp/nginx_scgi /var/log/nginx /var/lib/nginx /run/nginx; \
|
| 26 |
+
chmod -R g+rwX /data /einswarm /tmp/nginx_client_body /tmp/nginx_proxy /tmp/nginx_fastcgi /tmp/nginx_uwsgi /tmp/nginx_scgi /var/log/nginx /var/lib/nginx /run/nginx; \
|
| 27 |
+
ln -sf /usr/share/zoneinfo/Europe/Berlin /etc/localtime || true; \
|
| 28 |
+
echo "Europe/Berlin" > /etc/timezone || true; \
|
| 29 |
+
# Ensure tini path exists as /sbin/tini for ENTRYPOINT
|
| 30 |
+
if [ ! -x /sbin/tini ] && [ -x /usr/bin/tini ]; then ln -sf /usr/bin/tini /sbin/tini; fi
|
| 31 |
+
|
| 32 |
+
COPY nginx.conf /etc/nginx/nginx.conf
|
| 33 |
+
COPY settings.js /einswarm/settings.js
|
| 34 |
+
COPY einswarm-editor.css /einswarm/einswarm-editor.css
|
| 35 |
+
COPY bmc-loader.js /einswarm/bmc-loader.js
|
| 36 |
+
COPY assets/einswarm-logo.png /einswarm/einswarm-logo.png
|
| 37 |
+
COPY entrypoint.sh /entrypoint.sh
|
| 38 |
+
|
| 39 |
+
RUN chmod 755 /entrypoint.sh \
|
| 40 |
+
&& chmod 644 /etc/nginx/nginx.conf /einswarm/settings.js /einswarm/einswarm-editor.css /einswarm/bmc-loader.js \
|
| 41 |
+
&& chown -R node-red:root /einswarm /entrypoint.sh
|
| 42 |
+
|
| 43 |
+
ENV TZ=Europe/Berlin \
|
| 44 |
+
FLOWS=flows.json \
|
| 45 |
+
NODE_RED_ENABLE_SAFE_MODE=false
|
| 46 |
+
|
| 47 |
+
WORKDIR /usr/src/node-red
|
| 48 |
+
USER node-red
|
| 49 |
+
EXPOSE 7860
|
| 50 |
+
ENTRYPOINT ["/sbin/tini", "--", "/entrypoint.sh"]
|
README.md
CHANGED
|
@@ -1,10 +1,55 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: docker
|
|
|
|
| 7 |
pinned: false
|
|
|
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
title: Einswarm Node-RED
|
| 3 |
+
emoji: 🐝
|
| 4 |
+
colorFrom: yellow
|
| 5 |
+
colorTo: gray
|
| 6 |
sdk: docker
|
| 7 |
+
app_port: 7860
|
| 8 |
pinned: false
|
| 9 |
+
license: mit
|
| 10 |
+
short_description: Private Einswarm Node-RED (n8n-alternative) for 2Btainment
|
| 11 |
---
|
| 12 |
|
| 13 |
+
# Einswarm Node-RED (Docker Space)
|
| 14 |
+
|
| 15 |
+
Private Hugging Face Space running **Node-RED** in **Einswarm** black/gold style — a visual flow automation alternative to n8n.
|
| 16 |
+
|
| 17 |
+
## Access
|
| 18 |
+
|
| 19 |
+
This Space is **private**. Only HF accounts with Space access (owner `2Btainment` + collaborators) can open it.
|
| 20 |
+
|
| 21 |
+
## Open the app
|
| 22 |
+
|
| 23 |
+
- Space: https://huggingface.co/spaces/2Btainment/node-red
|
| 24 |
+
- **Direct URL (new tab):** https://2btainment-node-red.hf.space
|
| 25 |
+
|
| 26 |
+
nginx on **7860** proxies to Node-RED (**1880**) and allows framing by `huggingface.co` / `*.hf.space` (strips `X-Frame-Options` / CORP).
|
| 27 |
+
|
| 28 |
+
### Login
|
| 29 |
+
|
| 30 |
+
Editor auth uses Space secrets:
|
| 31 |
+
|
| 32 |
+
| Secret | Role |
|
| 33 |
+
|--------|------|
|
| 34 |
+
| `NODE_RED_ADMIN_USER` | Admin username (default `admin`) |
|
| 35 |
+
| `NODE_RED_ADMIN_PASSWORD` | Admin password (bcrypt-hashed at boot) |
|
| 36 |
+
| `NODE_RED_CREDENTIAL_SECRET` | Encrypts flow credentials — **do not rotate** |
|
| 37 |
+
|
| 38 |
+
Login with the admin user/password, then build flows.
|
| 39 |
+
|
| 40 |
+
## Persistence
|
| 41 |
+
|
| 42 |
+
Flows live under `/data` when writable. On HF **cpu-basic** without a volume, disk is **ephemeral** (wiped on rebuild/sleep). Export flows regularly.
|
| 43 |
+
|
| 44 |
+
## Buy Me a Coffee
|
| 45 |
+
|
| 46 |
+
Widget loads **async after editor mount** (no sync body script).
|
| 47 |
+
|
| 48 |
+
## Ops
|
| 49 |
+
|
| 50 |
+
German guide: `ANLEITUNG.md`.
|
| 51 |
+
|
| 52 |
+
## Health
|
| 53 |
+
|
| 54 |
+
- `GET /` → editor / login HTML (200)
|
| 55 |
+
- `GET /healthz` → proxied root (200 when up)
|
assets/einswarm-logo.png
ADDED
|
bmc-loader.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* Buy Me a Coffee — load AFTER editor UI mounts (async).
|
| 3 |
+
* Never use a sync body script (SpaceForge wipe lesson).
|
| 4 |
+
*/
|
| 5 |
+
(function () {
|
| 6 |
+
function inject() {
|
| 7 |
+
if (document.querySelector('script[data-name="bmc-button"]')) return;
|
| 8 |
+
var s = document.createElement("script");
|
| 9 |
+
s.setAttribute("data-name", "bmc-button");
|
| 10 |
+
s.setAttribute("data-cfasync", "false");
|
| 11 |
+
s.setAttribute("data-id", "2btainment");
|
| 12 |
+
s.setAttribute("data-description", "Support me on Buy me a coffee!");
|
| 13 |
+
s.setAttribute("data-message", "Einswarm — Danke für deinen Support!");
|
| 14 |
+
s.setAttribute("data-color", "#FFDD00");
|
| 15 |
+
s.setAttribute("data-position", "Right");
|
| 16 |
+
s.setAttribute("data-x_margin", "18");
|
| 17 |
+
s.setAttribute("data-y_margin", "18");
|
| 18 |
+
s.async = true;
|
| 19 |
+
s.src = "https://cdnjs.buymeacoffee.com/1.0.0/widget.prod.min.js";
|
| 20 |
+
document.body.appendChild(s);
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
if (document.readyState === "loading") {
|
| 24 |
+
document.addEventListener("DOMContentLoaded", function () {
|
| 25 |
+
setTimeout(inject, 800);
|
| 26 |
+
});
|
| 27 |
+
} else {
|
| 28 |
+
setTimeout(inject, 800);
|
| 29 |
+
}
|
| 30 |
+
})();
|
einswarm-editor.css
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* Einswarm black/gold Node-RED editor chrome */
|
| 2 |
+
:root {
|
| 3 |
+
--einswarm-bg: #020202;
|
| 4 |
+
--einswarm-panel: #0a0a0a;
|
| 5 |
+
--einswarm-gold: #FFDD00;
|
| 6 |
+
--einswarm-gold-dim: #C9A227;
|
| 7 |
+
--einswarm-text: #f5f5f0;
|
| 8 |
+
}
|
| 9 |
+
|
| 10 |
+
body.red-ui-editor,
|
| 11 |
+
body.red-ui-editor-offline,
|
| 12 |
+
#red-ui-header,
|
| 13 |
+
.red-ui-editor {
|
| 14 |
+
background-color: var(--einswarm-bg) !important;
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
#red-ui-header {
|
| 18 |
+
background: linear-gradient(90deg, #020202 0%, #12100a 50%, #020202 100%) !important;
|
| 19 |
+
border-bottom: 1px solid var(--einswarm-gold-dim) !important;
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
#red-ui-header .red-ui-header-logo span,
|
| 23 |
+
#red-ui-header .button,
|
| 24 |
+
#red-ui-header a {
|
| 25 |
+
color: var(--einswarm-gold) !important;
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
#red-ui-header .red-ui-deploy-button {
|
| 29 |
+
background: var(--einswarm-gold) !important;
|
| 30 |
+
color: #020202 !important;
|
| 31 |
+
border-color: var(--einswarm-gold-dim) !important;
|
| 32 |
+
font-weight: 700 !important;
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
.red-ui-palette,
|
| 36 |
+
#red-ui-sidebar,
|
| 37 |
+
.red-ui-sidebar {
|
| 38 |
+
background: var(--einswarm-panel) !important;
|
| 39 |
+
border-color: #2a2510 !important;
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
.red-ui-workspaces-tabs li a {
|
| 43 |
+
color: var(--einswarm-gold-dim) !important;
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
.red-ui-tabs {
|
| 47 |
+
background: #0d0d0d !important;
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
/* Login page */
|
| 51 |
+
.login-box,
|
| 52 |
+
#login-form,
|
| 53 |
+
body.login {
|
| 54 |
+
background: var(--einswarm-bg) !important;
|
| 55 |
+
color: var(--einswarm-text) !important;
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
.login-box button,
|
| 59 |
+
#login-submit {
|
| 60 |
+
background: var(--einswarm-gold) !important;
|
| 61 |
+
color: #020202 !important;
|
| 62 |
+
border: none !important;
|
| 63 |
+
font-weight: 700 !important;
|
| 64 |
+
}
|
entrypoint.sh
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env bash
|
| 2 |
+
set -euo pipefail
|
| 3 |
+
|
| 4 |
+
log() { echo "[entrypoint $(date -Iseconds)] $*"; }
|
| 5 |
+
|
| 6 |
+
export TZ="${TZ:-Europe/Berlin}"
|
| 7 |
+
export PORT=1880
|
| 8 |
+
export FLOWS="${FLOWS:-flows.json}"
|
| 9 |
+
|
| 10 |
+
if [ -d /data ] && [ -w /data ]; then
|
| 11 |
+
USER_DIR=/data
|
| 12 |
+
PERSIST_HINT="writable /data — still ephemeral on HF unless volume"
|
| 13 |
+
else
|
| 14 |
+
mkdir -p /tmp/node-red-data
|
| 15 |
+
USER_DIR=/tmp/node-red-data
|
| 16 |
+
PERSIST_HINT="ephemeral /tmp/node-red-data"
|
| 17 |
+
fi
|
| 18 |
+
mkdir -p "$USER_DIR"
|
| 19 |
+
log "Persistence: ${PERSIST_HINT}"
|
| 20 |
+
|
| 21 |
+
cp -f /einswarm/settings.js "$USER_DIR/settings.js"
|
| 22 |
+
|
| 23 |
+
ADMIN_USER="${NODE_RED_ADMIN_USER:-admin}"
|
| 24 |
+
ADMIN_PASS="${NODE_RED_ADMIN_PASSWORD:-}"
|
| 25 |
+
export NODE_RED_ADMIN_USER="$ADMIN_USER"
|
| 26 |
+
|
| 27 |
+
if [ -n "${NODE_RED_ADMIN_PASSWORD_HASH:-}" ]; then
|
| 28 |
+
log "Using pre-set NODE_RED_ADMIN_PASSWORD_HASH for user=${ADMIN_USER}"
|
| 29 |
+
elif [ -n "$ADMIN_PASS" ]; then
|
| 30 |
+
export NODE_RED_ADMIN_PASSWORD="$ADMIN_PASS"
|
| 31 |
+
HASH="$(
|
| 32 |
+
cd /usr/src/node-red
|
| 33 |
+
node -e '
|
| 34 |
+
const pw = process.env.NODE_RED_ADMIN_PASSWORD;
|
| 35 |
+
let bcrypt;
|
| 36 |
+
try { bcrypt = require("bcryptjs"); }
|
| 37 |
+
catch (e) {
|
| 38 |
+
try { bcrypt = require("/usr/src/node-red/node_modules/bcryptjs"); }
|
| 39 |
+
catch (e2) {
|
| 40 |
+
try { bcrypt = require("/usr/src/node-red/node_modules/node-red/node_modules/bcryptjs"); }
|
| 41 |
+
catch (e3) { console.error("bcryptjs missing"); process.exit(1); }
|
| 42 |
+
}
|
| 43 |
+
}
|
| 44 |
+
process.stdout.write(bcrypt.hashSync(pw, 8));
|
| 45 |
+
'
|
| 46 |
+
)"
|
| 47 |
+
export NODE_RED_ADMIN_PASSWORD_HASH="$HASH"
|
| 48 |
+
unset NODE_RED_ADMIN_PASSWORD
|
| 49 |
+
log "Generated admin password hash for user=${ADMIN_USER}"
|
| 50 |
+
else
|
| 51 |
+
log "WARNING: NODE_RED_ADMIN_PASSWORD unset — editor OPEN inside private HF gate"
|
| 52 |
+
fi
|
| 53 |
+
|
| 54 |
+
if [ -z "${NODE_RED_CREDENTIAL_SECRET:-}" ]; then
|
| 55 |
+
log "WARNING: NODE_RED_CREDENTIAL_SECRET unset"
|
| 56 |
+
else
|
| 57 |
+
log "NODE_RED_CREDENTIAL_SECRET is set (not logged)"
|
| 58 |
+
fi
|
| 59 |
+
|
| 60 |
+
# settings.js reads env at require-time
|
| 61 |
+
cp -f /einswarm/settings.js "$USER_DIR/settings.js"
|
| 62 |
+
|
| 63 |
+
mkdir -p /tmp/nginx_client_body /tmp/nginx_proxy /tmp/nginx_fastcgi /tmp/nginx_uwsgi /tmp/nginx_scgi
|
| 64 |
+
nginx -t
|
| 65 |
+
nginx
|
| 66 |
+
log "nginx listening on 0.0.0.0:7860 → 127.0.0.1:1880"
|
| 67 |
+
|
| 68 |
+
log "Starting Node-RED (userDir=${USER_DIR})"
|
| 69 |
+
cd /usr/src/node-red
|
| 70 |
+
|
| 71 |
+
# Match official image: node …/red.js --userDir /data
|
| 72 |
+
# Pass -s so our Einswarm settings (with env hash) are used.
|
| 73 |
+
exec node ${NODE_OPTIONS:-} node_modules/node-red/red.js --userDir "$USER_DIR" -s "$USER_DIR/settings.js"
|
nginx.conf
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
worker_processes 1;
|
| 2 |
+
error_log /tmp/nginx-error.log warn;
|
| 3 |
+
pid /tmp/nginx.pid;
|
| 4 |
+
|
| 5 |
+
events { worker_connections 1024; }
|
| 6 |
+
|
| 7 |
+
http {
|
| 8 |
+
include /etc/nginx/mime.types;
|
| 9 |
+
default_type application/octet-stream;
|
| 10 |
+
access_log /tmp/nginx-access.log;
|
| 11 |
+
sendfile on;
|
| 12 |
+
keepalive_timeout 65;
|
| 13 |
+
client_max_body_size 50m;
|
| 14 |
+
|
| 15 |
+
client_body_temp_path /tmp/nginx_client_body;
|
| 16 |
+
proxy_temp_path /tmp/nginx_proxy;
|
| 17 |
+
fastcgi_temp_path /tmp/nginx_fastcgi;
|
| 18 |
+
uwsgi_temp_path /tmp/nginx_uwsgi;
|
| 19 |
+
scgi_temp_path /tmp/nginx_scgi;
|
| 20 |
+
|
| 21 |
+
map $http_upgrade $connection_upgrade {
|
| 22 |
+
default upgrade;
|
| 23 |
+
'' close;
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
server {
|
| 27 |
+
listen 7860;
|
| 28 |
+
server_name _;
|
| 29 |
+
|
| 30 |
+
location = /healthz {
|
| 31 |
+
proxy_pass http://127.0.0.1:1880/;
|
| 32 |
+
proxy_set_header Host $host;
|
| 33 |
+
proxy_hide_header X-Frame-Options;
|
| 34 |
+
proxy_hide_header Cross-Origin-Resource-Policy;
|
| 35 |
+
add_header Content-Security-Policy "frame-ancestors 'self' https://huggingface.co https://*.hf.space;" always;
|
| 36 |
+
add_header Cache-Control "no-store";
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
location /einswarm-static/ {
|
| 40 |
+
alias /einswarm/;
|
| 41 |
+
expires 1d;
|
| 42 |
+
add_header Cache-Control "public";
|
| 43 |
+
add_header Content-Security-Policy "frame-ancestors 'self' https://huggingface.co https://*.hf.space;" always;
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
location / {
|
| 47 |
+
proxy_pass http://127.0.0.1:1880;
|
| 48 |
+
proxy_http_version 1.1;
|
| 49 |
+
proxy_set_header Host $host;
|
| 50 |
+
proxy_set_header X-Real-IP $remote_addr;
|
| 51 |
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
| 52 |
+
proxy_set_header X-Forwarded-Proto $scheme;
|
| 53 |
+
proxy_set_header X-Forwarded-Host $host;
|
| 54 |
+
proxy_set_header Authorization $http_authorization;
|
| 55 |
+
proxy_set_header Cookie $http_cookie;
|
| 56 |
+
proxy_set_header Upgrade $http_upgrade;
|
| 57 |
+
proxy_set_header Connection $connection_upgrade;
|
| 58 |
+
proxy_pass_header Set-Cookie;
|
| 59 |
+
proxy_hide_header X-Frame-Options;
|
| 60 |
+
proxy_hide_header Cross-Origin-Resource-Policy;
|
| 61 |
+
add_header Content-Security-Policy "frame-ancestors 'self' https://huggingface.co https://*.hf.space;" always;
|
| 62 |
+
proxy_read_timeout 3600s;
|
| 63 |
+
proxy_send_timeout 3600s;
|
| 64 |
+
proxy_buffering off;
|
| 65 |
+
}
|
| 66 |
+
}
|
| 67 |
+
}
|
settings.js
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* Einswarm Node-RED settings for Hugging Face Space.
|
| 3 |
+
* Password hash injected by entrypoint via NODE_RED_ADMIN_PASSWORD_HASH.
|
| 4 |
+
*/
|
| 5 |
+
const adminUser = process.env.NODE_RED_ADMIN_USER || "admin";
|
| 6 |
+
const adminHash = process.env.NODE_RED_ADMIN_PASSWORD_HASH || "";
|
| 7 |
+
const credentialSecret =
|
| 8 |
+
process.env.NODE_RED_CREDENTIAL_SECRET ||
|
| 9 |
+
process.env.NODE_RED_CREDENTIAL_SECRET_KEY ||
|
| 10 |
+
"";
|
| 11 |
+
|
| 12 |
+
const uiPort = parseInt(process.env.PORT || process.env.NODE_RED_PORT || "1880", 10);
|
| 13 |
+
|
| 14 |
+
module.exports = {
|
| 15 |
+
uiPort,
|
| 16 |
+
uiHost: "127.0.0.1",
|
| 17 |
+
httpAdminRoot: "/",
|
| 18 |
+
httpNodeRoot: "/",
|
| 19 |
+
userDir: "/data",
|
| 20 |
+
flowFile: process.env.FLOWS || "flows.json",
|
| 21 |
+
flowFilePretty: true,
|
| 22 |
+
credentialSecret: credentialSecret || undefined,
|
| 23 |
+
|
| 24 |
+
httpNodeCors: {
|
| 25 |
+
origin: "*",
|
| 26 |
+
methods: "GET,PUT,POST,DELETE,OPTIONS"
|
| 27 |
+
},
|
| 28 |
+
|
| 29 |
+
adminAuth: adminHash
|
| 30 |
+
? {
|
| 31 |
+
type: "credentials",
|
| 32 |
+
users: [
|
| 33 |
+
{
|
| 34 |
+
username: adminUser,
|
| 35 |
+
password: adminHash,
|
| 36 |
+
permissions: "*"
|
| 37 |
+
}
|
| 38 |
+
]
|
| 39 |
+
}
|
| 40 |
+
: undefined,
|
| 41 |
+
|
| 42 |
+
editorTheme: {
|
| 43 |
+
page: {
|
| 44 |
+
title: "Einswarm Node-RED",
|
| 45 |
+
favicon: "/einswarm/einswarm-logo.png",
|
| 46 |
+
css: "/einswarm/einswarm-editor.css",
|
| 47 |
+
scripts: ["/einswarm/bmc-loader.js"]
|
| 48 |
+
},
|
| 49 |
+
header: {
|
| 50 |
+
title: "Einswarm Node-RED",
|
| 51 |
+
image: "/einswarm/einswarm-logo.png",
|
| 52 |
+
url: "https://huggingface.co/spaces/2Btainment/node-red"
|
| 53 |
+
},
|
| 54 |
+
deployButton: {
|
| 55 |
+
type: "simple",
|
| 56 |
+
label: "Deploy",
|
| 57 |
+
icon: null
|
| 58 |
+
},
|
| 59 |
+
menu: {
|
| 60 |
+
"menu-item-help": {
|
| 61 |
+
label: "Einswarm / ANLEITUNG",
|
| 62 |
+
url: "https://huggingface.co/spaces/2Btainment/node-red/blob/main/ANLEITUNG.md"
|
| 63 |
+
}
|
| 64 |
+
},
|
| 65 |
+
userMenu: true,
|
| 66 |
+
login: {
|
| 67 |
+
image: "/einswarm/einswarm-logo.png"
|
| 68 |
+
},
|
| 69 |
+
logout: {
|
| 70 |
+
redirect: "https://huggingface.co/spaces/2Btainment/node-red"
|
| 71 |
+
},
|
| 72 |
+
projects: { enabled: false },
|
| 73 |
+
codeEditor: {
|
| 74 |
+
lib: "monaco",
|
| 75 |
+
options: { theme: "vs-dark" }
|
| 76 |
+
}
|
| 77 |
+
},
|
| 78 |
+
|
| 79 |
+
functionGlobalContext: {
|
| 80 |
+
einswarm: { brand: "Einswarm", owner: "2Btainment" }
|
| 81 |
+
},
|
| 82 |
+
|
| 83 |
+
logging: {
|
| 84 |
+
console: { level: "info", metrics: false, audit: false }
|
| 85 |
+
},
|
| 86 |
+
|
| 87 |
+
exportGlobalContextKeys: false,
|
| 88 |
+
externalModules: { autoInstall: false },
|
| 89 |
+
|
| 90 |
+
// Serve /einswarm/* for any direct asset requests
|
| 91 |
+
httpStatic: "/einswarm",
|
| 92 |
+
httpStaticRoot: "/einswarm/"
|
| 93 |
+
};
|