feat: web installer, setup mode, doctor command and Docker-first deploy#1763
Open
feat: web installer, setup mode, doctor command and Docker-first deploy#1763
Conversation
Adds a first-run web installer at /setup so new operators can complete configuration from the browser without hand-editing .env, plus a companion `bmwebui doctor` command and Docker compose stacks for production. The CLI setup wizard gains BanManager config auto-detection and transactional admin creation, and the seed/update commands share the same migration helper. Highlights - Setup mode: server boots without keys/DB and serves only /setup, /health and the installer assets. Refuses to expose the main UI until configuration is complete. - Web installer: vanilla JS wizard (HTML/CSS/JS shipped from server/setup/static) walks through env vars, DB connection, schema migration, BanManager server registration and admin user creation. Atomic finalize wraps server + admin creation in a single Knex tx. - bmwebui doctor: validates env, DB connection, migration status, admin presence, and pings each configured BanManager server (with encrypted password decryption). - bmwebui setup: optional auto-detect from BanManager plugin folder (config.yml + console.yml), reuses WebUI database when desired, shared createAdminUser helper, transactional inserts. - Apache + Caddy reverse-proxy generators (`bmwebui setup apache` / `bmwebui setup caddy`) with validated domain/subdirectory inputs. - Docker: multi-arch image build, docker-entrypoint.js auto-generates missing keys, docker-compose.prod.yml + docker-compose.prod-no-db.yml, /health endpoint reports setup_required vs ok for orchestration. - /health endpoint reuses the existing dbPool to avoid opening a new connection per request. Security hardening - Timing-safe comparison for SETUP_TOKEN. - Same-origin (Origin/Referer) check on /api/setup/* writes. - Strict regex validation for domain/subdirectory passed to shell. - parseBanManagerConfig restricted to config.yml/console.yml only. - BASE_PATH validated and HTML/JSON-escaped before injection. - MySQL healthcheck password moved out of CLI args via MYSQL_PWD. - docker-compose.prod.yml requires explicit DB credentials (no silent defaults). Tests - 8 new server-side suites covering setup state, finalize atomicity, env validation, key generation, parse-config, mode boot, basepath handling, and admin creation. - New test/lib/setup-fresh.js harness applies WebUI + BanManager migrations against an isolated DB so installer code can run in realistic conditions without mocks. - doctor positive/negative paths covered.
BanManager-WebUI
|
||||||||||||||||||||||||||||
| Project |
BanManager-WebUI
|
| Branch Review |
feat/easier-setup-web-installer
|
| Run status |
|
| Run duration | 00m 44s |
| Commit |
|
| Committer | James Mortemore |
| View all properties for this run ↗︎ | |
| Test results | |
|---|---|
|
|
0
|
|
|
0
|
|
|
0
|
|
|
0
|
|
|
26
|
| View all changes introduced in this branch ↗︎ | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a first-run web installer at
/setupso new operators can complete configuration from the browser without hand-editing.env, plus a companionbmwebui doctorcommand and production Docker compose stacks. The CLI setup wizard gains BanManager config auto-detection and transactional admin creation.The intent is to let a brand-new user go from
docker compose up(ornpm start) → browser → working WebUI in a few minutes, with the same UX available to bare-metal/CLI users.What's new
Setup mode
/setup,/healthand the installer assets./healthreportssetup_requiredvsok(consumed by Docker / orchestrators).Web installer
server/setup/static/) walks through env vars, DB connection, schema migration, BanManager server registration and admin user creation.bm_web_serversrow.bmwebui doctorbmwebui setupenhancementsconfig.yml+console.yml).createAdminUserhelper for transactional admin + role inserts.Reverse-proxy generators
bmwebui setup apacheandbmwebui setup caddyemit ready-to-use config from validated domain/subdirectory inputs.Docker
docker-entrypoint.jsauto-generates missing keys on first run.docker-compose.prod.yml(with bundled MySQL) anddocker-compose.prod-no-db.yml(BYO DB)./healthreportssetup_requiredorok.Dev tooling
scripts/seed.jsnow generates dev keys on first run and refuses to run withNODE_ENV=production.bmwebui updateshares the new migration helper.Security hardening
SETUP_TOKEN.Origin/Referer) check on/api/setup/*writes (CSRF protection).apachectl/caddy validate.parseBanManagerConfigrestricted toconfig.yml/console.ymlonly (no path traversal).BASE_PATHvalidated and HTML/JSON-escaped before injection into installer HTML.MYSQL_PWD.docker-compose.prod.ymlrequires explicit DB credentials (no silent defaults).Tests
server/test/lib/setup-fresh.jsharness applies WebUI + BanManager migrations against an isolated DB so installer code can run end-to-end.bmwebui doctorcovered with both negative (nothing configured) and positive (fully-seeded install) paths.setup/updatetests updated for the new "Done" output.Test plan
npm test(lint + Jest) — full suite is green locally (561 pass, 1 intentionally skipped; 2 known mutation tests are pre-existing parallelism flakes that pass in isolation).smoke_dockerjob runs compose stack and verifies/healthreportssetup_required./setupwith no env → wizard renders./→ main UI works,/setupredirects away.npx bmwebui doctorreports PASS on the seeded install.npx bmwebui setupauto-detects an existing BanManager plugin folder.npx bmwebui setup apache/caddyemit valid configs.Notes
SETUP_TOKENto require a bearer token if they need to expose/setupover the public internet during install.feat/ips; they are not part of this PR.