fix(dashboard): read the docs URL at runtime (#366)
CI / Check (push) Skipped
CI / Detect Changes (push) Successful in 4s
CI / Deploy Docs (push) Skipped
CI / Deploy MCP (push) Successful in 3m56s
CI / Deploy Dashboard (push) Successful in 5m35s
CI / Deploy Agent (push) Successful in 6m58s

This commit was merged in pull request #366.
This commit is contained in:
sharang committed 2026-09-25 07:54:07 +00:00
1 parent 33eb46df76
commit 79b8bef8ba
7 files changed
+64 -22

No files matched your search

+3
View File
@@ -109,6 +109,9 @@ DASHBOARD_SESSION_KEY=
# https://app-stage.breakpilot.com, production: https://app.breakpilot.com.
# Unset hides the link.
# PORTAL_URL=
# The docs site the sidebar links to. Default /docs/ (the docs container on
# the dashboard host); production uses https://docs.breakpilot.com/pruefwerk/.
# DOCS_URL=
# MCP Server
MCP_ENDPOINT_URL=http://localhost:8090
+1 -5
View File
@@ -2,17 +2,13 @@ FROM rust:1.94-bookworm AS builder
RUN cargo install dioxus-cli --version 0.7.3 --locked
# The docs site, served at /docs/ on the dashboard host. Keep the trailing
# slash: the orca route matches /docs/*, so plain /docs reaches the dashboard.
ARG DOCS_URL=/docs/
# Legal pages linked from the sidebar; the defaults are breakpilot.com's.
ARG IMPRINT_URL=https://breakpilot.com/impressum
ARG PRIVACY_URL=https://breakpilot.com/datenschutz
WORKDIR /app
COPY . .
ENV DOCS_URL=${DOCS_URL} \
IMPRINT_URL=${IMPRINT_URL} \
ENV IMPRINT_URL=${IMPRINT_URL} \
PRIVACY_URL=${PRIVACY_URL}
# compliance-agent (a workspace member) depends on the private firmwerk git
# repo, so the workspace resolve needs it even to build the dashboard.
+3
View File
@@ -15,4 +15,7 @@ pub struct AuthInfo {
/// there); empty when no portal is configured.
#[serde(default)]
pub portal_url: String,
/// The docs site this deployment links to from the sidebar.
#[serde(default)]
pub docs_url: String,
}
+10 -7
View File
@@ -10,7 +10,8 @@ use crate::i18n::texts::{common, nav};
use crate::i18n::{use_lang, Text};
use crate::infrastructure::platform::use_source_only;
/// Where the legal pages live. Overridable per build, like `DOCS_URL`.
/// Where the legal pages live. Overridable per build; they are the same on
/// staging and production.
const IMPRINT_URL: &str = match option_env!("IMPRINT_URL") {
Some(url) => url,
None => "https://breakpilot.com/impressum",
@@ -89,12 +90,14 @@ pub fn Sidebar() -> Element {
},
];
// With the trailing slash: the docs route matches /docs/*, and a plain
// /docs lands on the dashboard's "route not found" page.
let docs_url = option_env!("DOCS_URL").unwrap_or("/docs/");
// Back to the customer's workspace in the platform portal; hidden when
// the dashboard is not configured with one (local development).
let portal_url = use_context::<Signal<AuthInfo>>()().portal_url;
// Both links are set per deployment (`DOCS_URL`, `PORTAL_URL`). The
// portal link is hidden when the dashboard has no portal (local
// development).
let AuthInfo {
docs_url,
portal_url,
..
} = use_context::<Signal<AuthInfo>>()();
let sidebar_class = if collapsed() {
"sidebar collapsed"
@@ -21,6 +21,7 @@ pub async fn check_auth() -> Result<AuthInfo, ServerFnError> {
authenticated: true,
name: "Local User".into(),
portal_url: portal_link(state.portal_url.as_deref(), ""),
docs_url: state.docs_url.clone(),
..Default::default()
});
}
@@ -36,11 +37,15 @@ pub async fn check_auth() -> Result<AuthInfo, ServerFnError> {
Some(u) => Ok(AuthInfo {
authenticated: true,
portal_url: portal_link(state.portal_url.as_deref(), &u.tenant_slug),
docs_url: state.docs_url.clone(),
sub: u.sub,
email: u.user.email,
name: u.user.name,
avatar_url: u.user.avatar_url,
}),
None => Ok(AuthInfo::default()),
None => Ok(AuthInfo {
docs_url: state.docs_url.clone(),
..Default::default()
}),
}
}
@@ -17,6 +17,23 @@ use super::server_state::{ServerState, ServerStateInner};
use super::session_store::{load_session_key, MongoSessionStore};
use super::{auth_callback, auth_login, logout, require_auth, PendingOAuthStore};
/// The docs site when `DOCS_URL` is unset: served on the dashboard host.
/// Keep the trailing slash: the docs route matches `/docs/*`, and a plain
/// `/docs` lands on the dashboard's "route not found" page.
const DEFAULT_DOCS_URL: &str = "/docs/";
/// An optional setting from the environment, trimmed; unset or blank is `None`.
fn env_setting(name: &str) -> Option<String> {
non_blank(std::env::var(name).ok())
}
/// `value` trimmed, or `None` when it is missing or blank.
fn non_blank(value: Option<String>) -> Option<String> {
value
.map(|v| v.trim().to_string())
.filter(|v| !v.is_empty())
}
pub fn server_start(app: fn() -> Element) -> Result<(), DashboardError> {
tokio::runtime::Runtime::new()
.map_err(|e| DashboardError::Other(e.to_string()))?
@@ -53,15 +70,11 @@ pub fn server_start(app: fn() -> Element) -> Result<(), DashboardError> {
// Explicit MCP health URL — needed where an ingress strips the
// `/mcp` prefix (staging: `…/mcp/health` → compliance-mcp `/health`).
let mcp_health_url = std::env::var("MCP_HEALTH_URL")
.ok()
.map(|v| v.trim().to_string())
.filter(|v| !v.is_empty());
let portal_url = std::env::var("PORTAL_URL")
.ok()
.map(|v| v.trim().to_string())
.filter(|v| !v.is_empty());
let mcp_health_url = env_setting("MCP_HEALTH_URL");
let portal_url = env_setting("PORTAL_URL");
// Read at runtime: staging and production share one image but
// not one docs site.
let docs_url = env_setting("DOCS_URL").unwrap_or_else(|| DEFAULT_DOCS_URL.to_string());
// Sessions survive a redeploy: signed with a key from the
// environment, stored sealed in Mongo (#260).
@@ -82,6 +95,7 @@ pub fn server_start(app: fn() -> Element) -> Result<(), DashboardError> {
keycloak,
mcp_health_url,
portal_url,
docs_url,
}
.into();
@@ -196,3 +210,18 @@ async fn seed_default_mcp_servers(db: &Database, mcp_endpoint_url: Option<&str>)
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn blank_settings_count_as_unset() {
assert_eq!(
non_blank(Some(" https://docs.breakpilot.com/pruefwerk/ ".into())).as_deref(),
Some("https://docs.breakpilot.com/pruefwerk/")
);
assert_eq!(non_blank(Some(" ".into())), None);
assert_eq!(non_blank(None), None);
}
}
@@ -29,6 +29,9 @@ pub struct ServerStateInner {
/// differs between staging and production, which share one image, so it
/// is read at runtime. `None` hides the link.
pub portal_url: Option<String>,
/// The docs site for the sidebar link (`DOCS_URL`, default `/docs/`).
/// Read at runtime for the same reason as `portal_url`.
pub docs_url: String,
}
impl From<ServerStateInner> for ServerState {