Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Container Deployment (LXC)

BotServer uses LXC (Linux Containers) for isolated component deployment with system-level containerization.

What is LXC?

  • System containers - Full Linux userspace (lightweight VMs)
  • Shared kernel - More efficient than virtual machines
  • Isolation - Separate processes, networking, filesystems
  • Resource control - CPU, memory, I/O limits

Automatic Setup

./botserver --container

This automatically:

  1. Detects LXC/LXD availability
  2. Initializes LXD if needed
  3. Creates Debian 12 containers per component
  4. Mounts directories for persistent data
  5. Configures networking and ports
  6. Installs and starts services

Container Architecture

Container Naming

{tenant}-tables      → PostgreSQL
{tenant}-drive       → S3-compatible storage
{tenant}-cache       → Valkey cache
{tenant}-llm         → LLM server (optional)
{tenant}-email       → Mail server (optional)

Default tenant: defaultdefault-tables, default-drive, etc.

Directory Mounting

Host: botserver-stack/tables/data/  → Container: /opt/gbo/data/
Host: botserver-stack/tables/conf/  → Container: /opt/gbo/conf/
Host: botserver-stack/tables/logs/  → Container: /opt/gbo/logs/

Data persists even if containers are deleted.

Port Forwarding

Container PortHost PortService
54325432PostgreSQL
90009000Drive API
90019001Drive Console
63796379Cache

Common Operations

# List containers
lxc list

# Execute command in container
lxc exec default-tables -- psql -U gbuser botserver

# View logs
lxc exec default-tables -- journalctl -u tables

# Stop/Start
lxc stop default-tables
lxc start default-tables

# Delete (data in mounts persists)
lxc delete default-tables --force

Resource Limits

lxc config set default-tables limits.cpu 2
lxc config set default-tables limits.memory 4GB

Snapshots

# Create
lxc snapshot default-tables backup-2024-01-15

# List
lxc info default-tables

# Restore
lxc restore default-tables backup-2024-01-15

Troubleshooting

IssueSolution
LXC not installedsudo snap install lxd && sudo lxd init --auto
Permission deniedsudo usermod -aG lxd $USER && newgrp lxd
Container won’t startlxc console default-tables --show-log
Port in usesudo netstat -tulpn | grep PORT

Container vs Local

Use Containers WhenUse Local When
Clean isolation neededMaximum performance
Multiple instancesLXC not available
Easy cleanup/reinstallSimple deployment
Security isolationDirect service access

Migration

Local → Container

pg_dump botserver > backup.sql
./botserver --container
lxc exec default-tables -- psql -U gbuser botserver < backup.sql

Container → Local

lxc exec default-tables -- pg_dump -U gbuser botserver > backup.sql
./botserver uninstall tables
./botserver install tables --local
psql -U gbuser botserver < backup.sql

See Also