fix: container orchestration stability, AIUI inclusion, lnd-ui port, version 1.3.0

Container stability:
- Merge scan results instead of full replacement (prevents UI flapping)
- Absence threshold: 3 consecutive missed scans before removing from state
- container-list RPC uses cached scanner state for consistency
- Increased Podman API timeout 30s → 60s (scanner + health monitor)
- Keep crashed containers visible as "exited" instead of podman rm -f
- Resolve host-gateway IP via ip route (podman 4.3.x compatibility)

ISO build fixes:
- AIUI web app inclusion: searches 5 paths + CI step to copy from build server
- Claude API proxy: systemctl enable with symlink fallback
- AIUI nginx: try_files =404 (was /aiui/index.html redirect loop)
- Build version set to 1.3.0

Container fixes:
- lnd-ui: nginx listens on 8080 (was 80, Permission denied in rootless)
- first-boot: image-versions.sh sourced from correct path with validation
- first-boot: host-gateway resolved to actual gateway IP

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Dorian
2026-04-02 01:28:11 +01:00
co-authored by Claude Opus 4.6
parent 134de9fe3f
commit c62d7f77b5
13 changed files with 206 additions and 71 deletions
@@ -192,7 +192,9 @@ impl RpcHandler {
}
// DNS: ensure host.containers.internal resolves (needed for Tor proxy, inter-service calls)
run_args.push("--add-host=host.containers.internal:host-gateway");
// Rootless podman 4.3.x doesn't support "host-gateway" — resolve to actual gateway IP
let host_gateway_flag = resolve_host_gateway().await;
run_args.push(&host_gateway_flag);
// Security hardening (skip for privileged containers)
let security_caps: Vec<String> = if !is_tailscale {
@@ -340,6 +342,8 @@ impl RpcHandler {
}
if state == "exited" {
// Container crashed immediately — get logs for diagnosis
// Keep the container (don't rm) so it shows as "exited" in My Apps
// instead of vanishing completely. User can retry or remove manually.
let logs = tokio::process::Command::new("podman")
.args(["logs", "--tail", "20", container_name])
.output()
@@ -351,11 +355,7 @@ impl RpcHandler {
format!("{}{}", stdout, stderr)
})
.unwrap_or_default();
install_log(&format!("INSTALL CRASH: {} — container exited. Logs:\n{}", package_id, &log_output.chars().take(1000).collect::<String>())).await;
let _ = tokio::process::Command::new("podman")
.args(["rm", "-f", container_name])
.output()
.await;
install_log(&format!("INSTALL CRASH: {} — container exited (kept for visibility). Logs:\n{}", package_id, &log_output.chars().take(1000).collect::<String>())).await;
return Err(anyhow::anyhow!(
"Container {} exited immediately after start. Logs: {}",
container_name,
@@ -936,3 +936,39 @@ autopilot.active=false\n",
Ok(serde_json::json!({ "token": token }))
}
}
/// Resolve the host gateway IP for --add-host flag.
/// Podman 4.3.x (Debian 12) doesn't support "host-gateway" in rootless mode,
/// so we resolve the default gateway IP from the routing table.
async fn resolve_host_gateway() -> String {
// Try `ip route` to get the default gateway
if let Ok(output) = tokio::process::Command::new("ip")
.args(["route", "show", "default"])
.output()
.await
{
let stdout = String::from_utf8_lossy(&output.stdout);
for line in stdout.lines() {
if line.starts_with("default") {
if let Some(gw) = line.split_whitespace().nth(2) {
if !gw.is_empty() {
return format!("--add-host=host.containers.internal:{}", gw);
}
}
}
}
}
// Fallback: try hostname -I (first IP)
if let Ok(output) = tokio::process::Command::new("hostname")
.args(["-I"])
.output()
.await
{
let stdout = String::from_utf8_lossy(&output.stdout);
if let Some(ip) = stdout.split_whitespace().next() {
return format!("--add-host=host.containers.internal:{}", ip);
}
}
// Last resort
"--add-host=host.containers.internal:10.0.2.2".to_string()
}