feat(onprem): APP_ENV=onprem for a customer's own node

The registry on a customer's node must never reach a Breakpilot host and
must not run the cloud's commercial machinery.

- APP_ENV=onprem: no ERP (nothing queued, webhook off), no trial (new
  workspaces start active, the ladder never escalates by time), and the
  trial-offer, trial-terms, catalog/trial request and admin trial routes
  answer 404 not_available.
- PRODUCTS, PRODUCT_LAUNCH_URLS, PRODUCT_PROVISION_URLS: one store
  decorator applies the product list and URLs to every catalog read
  (catalog, activation, provisioning, entitlement checks). On-prem has no
  seeded URLs, so provisioning goes only to the local products. Checked at
  start ({id} in provision URLs, absolute http(s)).
- On-prem start fails when the values leave something to a cloud or dev
  default (auth off, no authz rules, ephemeral licence key, portal, invite,
  sender, LLM gateway) or set an ERP or contract documents.
- SMTP_TLS=starttls|tls|none: a plain relay inside the customer's network;
  no AUTH without encryption.
- Migration 0032: the Werkpilot text no longer names our LLM host.

Cloud behaviour is unchanged without the new variables (tested).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 2f6fa5f3e8)
This commit is contained in:
Sharang Parnerkar committed 2026-11-20 17:08:42 +01:00
1 parent c6de35858e
commit a4fb318773
18 files changed
+786 -30

No files matched your search

+8 -2
View File
@@ -82,6 +82,12 @@ func main() {
s = pg
}
defer s.Close()
kind := storeKind(s)
// PRODUCTS / PRODUCT_*_URLS (on-prem: the only source of product URLs).
s = store.WithProductOverrides(s, cfg.CatalogEnv(), cfg.Products, cfg.LaunchURLs, cfg.ProvisionURLs)
if cfg.OnPrem() {
slog.Info("on-prem mode: no ERP, no trial ladder, no sign-up", "products", cfg.Products)
}
var kc keycloak.Adapter
if cfg.KeycloakAdminURL != "" && cfg.KeycloakClientID != "" {
@@ -189,7 +195,7 @@ func main() {
logger.Warn("DOCUMENTS_S3_* not set; document routes answer 503")
}
var mailer mail.Sender
if mc := (mail.Config{Host: cfg.SMTPHost, Port: cfg.SMTPPort, User: cfg.SMTPUser, Password: cfg.SMTPPassword, From: cfg.MailFrom, FromName: cfg.MailFromName}); mc.Configured() {
if mc := (mail.Config{Host: cfg.SMTPHost, Port: cfg.SMTPPort, User: cfg.SMTPUser, Password: cfg.SMTPPassword, From: cfg.MailFrom, FromName: cfg.MailFromName, TLS: cfg.SMTPTLS}); mc.Configured() {
mailer = &mail.SMTP{Cfg: mc}
}
app := &server.Server{Cfg: cfg, Log: logger, Store: s, Keycloak: kc, Auth: av, Authz: authz, Product: pv, ERP: erpClient, Licences: signer, LLMKeys: llmKeys, Secrets: secrets, Objects: objects, Mail: mailer}
@@ -215,7 +221,7 @@ func main() {
go app.RunModuleUserCount(ctx, 15*time.Minute)
go func() {
slog.Info("tenant-registry listening", "addr", cfg.Addr, "env", cfg.Env, "store", storeKind(s))
slog.Info("tenant-registry listening", "addr", cfg.Addr, "env", cfg.Env, "store", kind)
if err := srv.ListenAndServe(); err != nil && !errors.Is(err, http.ErrServerClosed) {
slog.Error("server crashed", "err", err)
os.Exit(1)