This is an automated email from the ASF dual-hosted git repository. wu-sheng pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/skywalking-horizon-ui.git
commit c4df7d8cc0ae8644ecf84acc79654489886ac651 Author: Wu Sheng <[email protected]> AuthorDate: Mon May 18 21:47:34 2026 +0800 docker: zero-config boot — HORIZON_SERVER_HOST=0.0.0.0 by default in the image Without this the container booted but bound `127.0.0.1` (the schema default), which inside Docker is container-internal-loopback — `docker run -p 8081:8081 horizon-ui:local` (no config mount) reached the published port but got 502s with no clear cause. An operator trying the image with zero arguments hit this immediately. Added env-var fallbacks for `server.host` / `server.port` in the config schema (same pattern as the existing `HORIZON_AUDIT_FILE` / `HORIZON_SETUP_FILE` / `HORIZON_ALARMS_FILE` / `HORIZON_WIRE_LOG_FILE` overrides). An explicit value in `horizon.yaml` still wins. The Dockerfile sets `HORIZON_SERVER_HOST=0.0.0.0` and `HORIZON_SERVER_PORT=8081` so the image's out-of-the-box behaviour is: - boot in unconfigured state (warns, doesn't crash — already wired) - bind to 0.0.0.0:8081 so the published port reaches the BFF - serve the login page showing the "Auth not configured" banner Verified: `docker run --rm -p 8081:8081 horizon-ui:local` reaches the SPA + API; health endpoint reports configured: false + setupHint; logs quiet at default error level; LOG_LEVEL=info opens the access log. --- Dockerfile | 2 ++ apps/bff/src/config/schema.ts | 16 ++++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index c55f6d0..336b28a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -59,6 +59,8 @@ RUN mkdir -p /data && chown horizon:horizon /data VOLUME ["/data"] ENV NODE_ENV=production \ + HORIZON_SERVER_HOST=0.0.0.0 \ + HORIZON_SERVER_PORT=8081 \ HORIZON_STATIC_DIR=/app/static \ HORIZON_CONFIG=/app/horizon.yaml \ HORIZON_AUDIT_FILE=/data/horizon-audit.jsonl \ diff --git a/apps/bff/src/config/schema.ts b/apps/bff/src/config/schema.ts index ecb3aed..bd4b118 100644 --- a/apps/bff/src/config/schema.ts +++ b/apps/bff/src/config/schema.ts @@ -17,10 +17,22 @@ import { z } from 'zod'; +// Env-var-overridable bind defaults. The Docker image sets +// `HORIZON_SERVER_HOST=0.0.0.0` so a zero-config `docker run -p 8081:8081 +// horizon-ui:local` reaches the BFF (the YAML default `127.0.0.1` would +// bind container-loopback and silently 502 from the host side). An +// explicit `server.host`/`server.port` in horizon.yaml always wins. +const serverHostDefault = process.env.HORIZON_SERVER_HOST ?? '127.0.0.1'; +const serverPortDefault = (() => { + const raw = process.env.HORIZON_SERVER_PORT; + if (!raw) return 8081; + const n = Number(raw); + return Number.isFinite(n) && n > 0 ? Math.floor(n) : 8081; +})(); const serverSchema = z .object({ - host: z.string().default('127.0.0.1'), - port: z.number().int().positive().default(8081), + host: z.string().default(serverHostDefault), + port: z.number().int().positive().default(serverPortDefault), staticDir: z.string().optional(), }) .strict();
