From 10a5b815bd826914244db0f5efe5d93c015dc785 Mon Sep 17 00:00:00 2001 From: Carter Bourette Date: Thu, 14 Nov 2024 21:04:21 -0330 Subject: [PATCH] feat: Add environment configuration to disable Web UI --- README.md | 1 + cmd/server/main.go | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/README.md b/README.md index 2f2bd1dd..2d3d0e77 100644 --- a/README.md +++ b/README.md @@ -207,6 +207,7 @@ PONG | `HTTP_ADMIN_BIND_ADDRESS` | Address to bind admin HTTP server on. This overrides the command-line flag `-admin.addr`. | Default: `:9094` | | `HTTPS_CERT_FILE` | Filepath containing a certificate (or intermediate chain) to be served by the HTTP server. Requires all traffic be over secure HTTP. | Empty | | `HTTPS_KEY_FILE` | Filepath of a private key matching the leaf certificate from `HTTPS_CERT_FILE`. | Empty | +| `DISABLE_WEB_UI` | Skip serving and setup of the web UI. | Default: `false` | | `WEB_ROOT` | Directory to serve web UI from. | Default: `webui/` | | `WEBHOOK_MAX_WORKERS` | Maximum number of workers processing webhooks. | Default: 10 | | `DOWNLOAD_WEBHOOK_URL` | Optional webhook URL called when data downloads / refreshes occur. | Empty | diff --git a/cmd/server/main.go b/cmd/server/main.go index 90ef6705..58802c57 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -234,6 +234,16 @@ func getDataRefreshInterval(logger log.Logger, env string) time.Duration { } func setupWebui(logger log.Logger, r *mux.Router, basePath string) { + var disableWebUI bool + if val, err := strconv.ParseBool(os.Getenv("DISABLE_WEB_UI")); err == nil { + disableWebUI = val + } + + if disableWebUI { + logger.Log("Disabling webui") + return + } + dir := os.Getenv("WEB_ROOT") if dir == "" { dir = filepath.Join("webui", "build")