tools: update inside LXC and use the existing proxy
agent-review agent review: fail

Keep the Proxmox host responsible only for container creation. Serve the private backend on port 5187 behind the operator's HTTPS proxy and install a self-updating in-container command. Preserve existing identity and history while migrating the old installer-owned proxy with listener rollback.

Refs #21
This commit is contained in:
Florian Schmidt
2026-11-15 12:49:53 +01:00
parent c75446008c
commit 7b70c7a0fa
20 changed files with 617 additions and 607 deletions
+41
View File
@@ -0,0 +1,41 @@
"""Allowlisted application source shared by CT creation and in-container updates."""
import hashlib
from pathlib import Path
import sys
import tarfile
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
from source_policy import is_private_path
PROJECTS = ("FinalToken.Core", "FinalToken.Fleet", "FinalToken.Web", "FinalToken.Worker")
def snapshot(source, destination):
"""Allowlist source inputs, including uncommitted changes, excluding secrets, outputs and symlinks."""
files = [source / n for n in ("Directory.Build.props", "Directory.Packages.props", "global.json", "LICENSE", "tools/lxc_update.py")]
for project in PROJECTS:
directory = source / "src" / project
if directory.is_symlink() or directory.resolve() != directory.absolute():
raise ValueError("Source snapshot refuses a symlinked project or parent: " + project)
files.extend(directory.rglob("*"))
total, count = 0, 0
with tarfile.open(destination, "w:gz") as archive:
for path in sorted(set(files)):
relative = path.relative_to(source)
if is_private_path(relative):
continue # .gitignore does not apply to tarfile: do not copy local deployment data.
if any(p in ("bin", "obj", "artifacts", ".git", "node_modules") or p.startswith(".") for p in relative.parts):
continue
if path.is_symlink() or path.resolve() != path.absolute():
raise ValueError("Source snapshot refuses symlinks: " + str(relative))
if path.is_dir():
continue
if not path.is_file():
raise ValueError("Missing or non-regular source file: " + str(relative))
size = path.stat().st_size
total += size
count += 1
if size > 16 * 1024 * 1024 or total > 256 * 1024 * 1024 or count > 10000:
raise ValueError("Source snapshot exceeds the guest archive bounds")
archive.add(path, arcname=relative.as_posix(), recursive=False)
return hashlib.sha256(destination.read_bytes()).hexdigest()