// CONTENTS Part 02 · Build, run, scale

// PART 02

Containers: Docker, Kubernetes, Incus

Chapter 11 / 56 3 min read English Part 02 of 14

Containers are Incus instances. lxc/lxd are not a supported runtime for this project: AGENTS.md states Incus is the only container layer, and the bootstrap code calls incus directly (botserver/crates/botcore/src/package_manager/container/bootstrap_container_inner.rs).

⚠️ All container commands run on the host, not inside a container.

Prerequisites

sudo apt install incus
sudo incus admin init --auto
sudo usermod -aG incus-admin "$USER"   # then log out and back in

Membership of incus-admin is what lets a non-root user talk to the Incus socket; without it every incus command fails with a permission error.

Automatic setup

./botserver --container

--container selects container mode (botserver/src/main_module/init.rs, botserver/crates/botcorepkg/src/cli.rs). The installer then, per component:

  1. creates {tenant}-{component} as an Incus instance (botserver/crates/botcore/src/package_manager/facade/install.rs),
  2. copies the component’s binaries and configuration,
  3. adds an eth0 NIC and the port proxy devices (bootstrap_container_inner.rs),
  4. starts the systemd unit inside the instance.

Images are tried in order: ubuntu:24.04, ubuntu:22.04, images:debian/12, images:debian/11 — the first that launches wins.

Run contract of a container

How a component is isolated, how much it may consume and which ports leave the instance is one typed declaration, not a set of literals spread over the installer: botcorepkg::container::ContainerSettings (crates/botcorepkg/src/container.rs). The container creation path (facade/install_container.rs), the proxy devices (facade/setup_port_forwarding.rs) and the host NAT path (container/configure_iptables_nat.rs) consume it; none of them decides a limit, a security.* flag or a bind address on its own.

ComponentConfig::container_settings(tenant) resolves the contract for a registration. A registration with container: None gets the documented defaults, which are the pre-#3112 install: {tenant}-{name}, user gbuser, working directory /opt/gbo, security.privileged=true, no CPU, memory or disk ceiling, and every declared port in ports treated as both internal and published. Registering container: Some(...) overrides only the fields it sets.

The exposure rule: a port is published only when it is listed in published_ports. A database, cache or vault keeps its listener off the host by declaring internal_ports and leaving published_ports empty.

Generated configuration files

Three components get their configuration rendered by the installer, not hand-written:

Component File Rendered by
Proxy conf/Caddyfile — sites system.<domain> → 8080, chat.<domain> → 3000, login.<domain> → 5000, alm.<domain> → 4747 botcorepkg::proxy_config from InfraDefaults
DNS conf/dns/Corefile + conf/dns/<domain>.zone (one A record per service) dns_config::ensure_defaults
Meet conf/meet/config.yaml + TLS pair meet_config::ensure_meet_config

All three renders are idempotent (identical inputs, identical bytes), back up the previous file before replacing it, and validate before start (Caddy runs caddy validate; a rejected file aborts the start).

Naming and mounts

Instance Component
{tenant}-tables PostgreSQL
{tenant}-drive object storage (OtterIO)
{tenant}-cache Valkey
{tenant}-llm llama.cpp (optional)
{tenant}-email mail server (optional)

Data lives on host mounts, so deleting an instance does not delete data (botserver-stack/tables/data/ → /opt/gbo/data/, same for conf/ and logs/).

Container names are derived, never taken verbatim from user input: the installer uses {tenant}-{component}; Vibe derives {project}-{env}[-runner] and refuses the platform’s own names (is_protected_container_name); the deployment gateway accepts only [A-Za-z0-9_-].

Runtime rules the build enforces

Two rules are checked mechanically (python3 scripts/check_container_runtime.py --check):

Rule What fails the build
Incus is the only container layer any spawn of lxc, lxd or lxc-execute
Incus is spawned through SafeCommand raw std::process::Command::new("incus") or its tokio form

SafeCommand (botsecurity-core/src/command_guard.rs) adds the binary allowlist, argv validation and a scrubbed environment.

Common operations

incus list
incus exec default-tables -- psql -U gbuser botserver
incus exec default-tables -- journalctl -u tables
incus config set default-tables limits.memory 4GiB
incus snapshot create default-tables pre-upgrade-$(date +%Y%m%d)
incus delete default-tables --force     # host mounts persist

Migration host ↔ container

# host → container
pg_dump botserver > /tmp/backup.sql
./botserver --container
incus exec default-tables -- psql -U gbuser botserver < /tmp/backup.sql

# container → host
incus exec default-tables -- pg_dump -U gbuser botserver > /tmp/backup.sql
./botserver uninstall tables
./botserver install tables --local
psql -U gbuser botserver < /tmp/backup.sql

Found a mistake? Open an issue · All books

// SEARCH ESC
Pagefind · 236 pages · 4 books Enter to open ↑ ↓ to move