From 2bbb89c53ff29700aa29f979f2d03dbf7e114379 Mon Sep 17 00:00:00 2001 From: Dorian Date: Sat, 9 May 2026 16:26:18 +0100 Subject: [PATCH] Stabilize Datum container networking --- .env.example | 8 +++----- README.md | 13 +++++++------ apps/api/src/datum/poller.ts | 2 +- docker-compose.yml | 23 +++++++++++++---------- 4 files changed, 24 insertions(+), 22 deletions(-) diff --git a/.env.example b/.env.example index 9e80cc9..1a96368 100644 --- a/.env.example +++ b/.env.example @@ -13,11 +13,9 @@ LOG_LEVEL=info # STATIC_DIR= # ---- Datum gateway (the Umbrel app we're polling) ---- -# Umbrel/Portainer stacks cannot reliably resolve Datum's container name. -# Use Datum's current IP on umbrel_main_network and refresh it if Umbrel -# recreates the Datum container: -# docker inspect -f '{{.NetworkSettings.Networks.umbrel_main_network.IPAddress}}' datum_datum_1 -DATUM_URL=http://10.21.0.11:21000 +# Use Docker DNS on umbrel_main_network so Datum can be recreated without +# changing a stale container IP. +DATUM_URL=http://datum_datum_1:21000 DATUM_ADMIN_USER=admin DATUM_ADMIN_PASSWORD= # How often to scrape /clients (ms). Datum updates per-worker hashrate every diff --git a/README.md b/README.md index e203dca..98d4498 100644 --- a/README.md +++ b/README.md @@ -46,12 +46,13 @@ Allowlist of npubs is set via `NOSTR_ALLOWED_NPUBS`. Anything else is rejected b - Repository URL: `https://git.tx1138.com/lfg2025/gashboard` - Compose path: `docker-compose.yml` - Add env vars (see `.env.example`) - - Set `DATUM_URL` to Datum's current container IP: - ```bash - docker inspect -f '{{.NetworkSettings.Networks.umbrel_main_network.IPAddress}}' datum_datum_1 - ``` - - Use it as `DATUM_URL=http://:21000`. - - If Datum/Umbrel recreates the container, refresh this IP in Portainer and redeploy. + - Remove any old `DATUM_URL=http://10.21...` value from the stack env vars. + Leave `DATUM_URL` unset unless your Datum container name is different. By + default the stack uses `http://datum_datum_1:21000` on Umbrel's + `umbrel_main_network`, so Datum can be recreated without changing a stale + IP address. + - If your Umbrel install uses a different Datum container name, set + `DATUM_URL=http://:21000`. 4. Open the dashboard, log in with one of the allowed npubs, watch your boards lose at hashing in style. diff --git a/apps/api/src/datum/poller.ts b/apps/api/src/datum/poller.ts index ad5c8b7..a6265d6 100644 --- a/apps/api/src/datum/poller.ts +++ b/apps/api/src/datum/poller.ts @@ -64,7 +64,7 @@ function formatErr(err: unknown): string { const datumHost = new URL(config.datum.url).hostname; const hint = hostname === datumHost - ? "; check DATUM_NETWORK or set DATUM_URL to a hostname/IP reachable from the gashboard API container" + ? "; make sure gashboard is attached to Umbrel's Docker network or set DATUM_URL to a hostname/IP reachable from the API container" : ""; return `${err.message}: DNS could not resolve ${hostname} (${code})${hint}`; } diff --git a/docker-compose.yml b/docker-compose.yml index b0cc00c..bfc5901 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,10 +1,7 @@ -version: "3.9" - # gashboard — deploy as a Portainer Stack on the same Umbrel host that runs Datum. # -# Umbrel's Portainer setup cannot reliably resolve Umbrel app container names -# from repository stacks. Use host networking and point DATUM_URL at Datum's -# current container IP on umbrel_main_network. +# Join Umbrel's shared Docker network so the API can reach Datum by container +# DNS name instead of a changing container IP. services: gashboard: @@ -24,10 +21,9 @@ services: PORT: "1337" LOG_LEVEL: "${LOG_LEVEL:-info}" CORS_ORIGIN: "${CORS_ORIGIN:-}" - # Reach the Datum gateway container directly. Refresh this IP if Umbrel - # recreates Datum: - # docker inspect -f '{{.NetworkSettings.Networks.umbrel_main_network.IPAddress}}' datum_datum_1 - DATUM_URL: "${DATUM_URL?must be set, e.g. http://10.21.0.11:21000}" + # Reach the Datum gateway container through Docker DNS on Umbrel's shared + # network. This avoids hard-coding Datum's changing container IP. + DATUM_URL: "${DATUM_URL:-http://datum_datum_1:21000}" DATUM_ADMIN_USER: "${DATUM_ADMIN_USER:-admin}" DATUM_ADMIN_PASSWORD: "${DATUM_ADMIN_PASSWORD?must be set}" DATUM_POLL_INTERVAL_MS: "${DATUM_POLL_INTERVAL_MS:-5000}" @@ -35,10 +31,17 @@ services: NOSTR_ALLOWED_NPUBS: "${NOSTR_ALLOWED_NPUBS?must be set}" JWT_SECRET: "${JWT_SECRET?must be set}" JWT_TTL_SECONDS: "${JWT_TTL_SECONDS:-86400}" - network_mode: host + ports: + - "${PORT:-1337}:1337" + networks: + - umbrel_main_network healthcheck: test: ["CMD", "wget", "-qO-", "http://127.0.0.1:1337/healthz"] interval: 30s timeout: 5s retries: 3 start_period: 15s + +networks: + umbrel_main_network: + external: true