|
| 1 | +# Terrarium |
| 2 | + |
| 3 | +Terrarium bootstraps a single Ubuntu 24.04 VPS into a ZFS-backed LXD host for isolated workloads. |
| 4 | + |
| 5 | +The intended entrypoint is: |
| 6 | + |
| 7 | +```bash |
| 8 | +curl -fsSL https://raw.githubusercontent.com/terion-name/terrarium/refs/heads/main/install.sh | bash |
| 9 | +``` |
| 10 | + |
| 11 | +The shell bootstrap is intentionally thin. It downloads a compiled `terrariumctl` bundle from GitHub Releases when possible, clones the Terrarium repo into `/opt/terrarium`, stages the bundled binary into that checkout, and falls back to a source build only when you target a branch-like `--ref` such as `main`. |
| 12 | + |
| 13 | +Terrarium provisions the host with: |
| 14 | + |
| 15 | +- Cockpit |
| 16 | +- `45Drives/cockpit-zfs` |
| 17 | +- `45Drives/cockpit-S3ObjectBroswer` |
| 18 | +- LXD with the built-in web UI |
| 19 | +- ZFS |
| 20 | +- `sanoid` and optional `syncoid` |
| 21 | +- Traefik for public management endpoints |
| 22 | +- Optional self-hosted ZITADEL at `auth.<domain>` |
| 23 | +- `devsec.hardening` OS and SSH hardening |
| 24 | + |
| 25 | +## Supported Host |
| 26 | + |
| 27 | +- Ubuntu Server 24.04 LTS |
| 28 | +- Single-host install only |
| 29 | +- LXC containers only |
| 30 | + |
| 31 | +## Install Modes |
| 32 | + |
| 33 | +Interactive: |
| 34 | + |
| 35 | +```bash |
| 36 | +curl -fsSL https://raw.githubusercontent.com/terion-name/terrarium/refs/heads/main/install.sh | bash -s -- --interactive |
| 37 | +``` |
| 38 | + |
| 39 | +Non-interactive: |
| 40 | + |
| 41 | +```bash |
| 42 | +curl -fsSL https://raw.githubusercontent.com/terion-name/terrarium/refs/heads/main/install.sh | bash -s -- \ |
| 43 | + --non-interactive \ |
| 44 | + --email admin@example.com \ |
| 45 | + --idp-mode zitadel-self-hosted \ |
| 46 | + --storage-mode loop \ |
| 47 | + --yes |
| 48 | +``` |
| 49 | + |
| 50 | +## Storage Strategy |
| 51 | + |
| 52 | +Recommended: |
| 53 | + |
| 54 | +- Attach a dedicated block volume and use `--storage-mode disk`. |
| 55 | + |
| 56 | +Fallback: |
| 57 | + |
| 58 | +- If the VPS only has the default root disk, Terrarium can create a file-backed ZFS pool with `--storage-mode loop`. |
| 59 | + |
| 60 | +Partition mode: |
| 61 | + |
| 62 | +- `--storage-mode partition` is intended for an existing safe partition target or a non-root whole disk that Terrarium can partition. |
| 63 | +- Terrarium does not try to shrink the mounted root filesystem. |
| 64 | + |
| 65 | +## Public Endpoints |
| 66 | + |
| 67 | +By default, Terrarium exposes: |
| 68 | + |
| 69 | +- `https://manage.<dashed-public-ip>.traefik.me` for Cockpit |
| 70 | +- `https://lxd.<dashed-public-ip>.traefik.me` for the LXD API and UI |
| 71 | +- `https://auth.<dashed-public-ip>.traefik.me` for self-hosted ZITADEL when `--idp-mode zitadel-self-hosted` is enabled |
| 72 | + |
| 73 | +You can override the domains with: |
| 74 | + |
| 75 | +- `--domain` |
| 76 | +- `--manage-domain` |
| 77 | +- `--lxd-domain` |
| 78 | +- `--auth-domain` |
| 79 | + |
| 80 | +## Reconfiguration |
| 81 | + |
| 82 | +The installer keeps the checked out repository at `/opt/terrarium` and writes the resolved config to `/etc/terrarium/config.yaml`. |
| 83 | + |
| 84 | +After installation: |
| 85 | + |
| 86 | +```bash |
| 87 | +terrariumctl status |
| 88 | +terrariumctl backup list |
| 89 | +terrariumctl backup export |
| 90 | +terrariumctl backup restore --source s3 --instance app --at 2026-04-12T12 --as-new app-restore |
| 91 | +terrariumctl reconfigure |
| 92 | +terrariumctl proxy sync |
| 93 | +terrariumctl idp sync |
| 94 | +terrariumctl setdomain example.com |
| 95 | +``` |
| 96 | + |
| 97 | +`terrariumctl setdomain` updates the persisted root domain, derives `manage.`, `lxd.`, and `auth.` subdomains unless you override them, and then re-runs the full Ansible reconciliation so Traefik, LXD, and ZITADEL pick up the new external hostnames. |
| 98 | + |
| 99 | +When self-hosted ZITADEL is enabled, Terrarium generates the initial admin password at `/etc/terrarium/secrets/zitadel_admin_password`. |
| 100 | + |
| 101 | +## LXC Proxy Labels |
| 102 | + |
| 103 | +Terrarium can sync LXC `user.proxy` labels into Traefik every minute. |
| 104 | + |
| 105 | +Examples: |
| 106 | + |
| 107 | +```bash |
| 108 | +lxc config set my-app user.proxy "https://app.example.com:3000,http://app-insecure.example.com:3000" |
| 109 | +lxc config set game user.proxy "tcp://25565:25565,udp://19132:19132" |
| 110 | +``` |
| 111 | + |
| 112 | +Rules: |
| 113 | + |
| 114 | +- `https://domain[:container_port][/path]` creates HTTP-to-HTTPS redirect plus a TLS router. |
| 115 | +- `http://domain[:container_port][/path]` creates an HTTP router only. |
| 116 | +- `tcp://hostport:containerport` exposes a raw TCP port through Traefik. |
| 117 | +- `udp://hostport:containerport` exposes a raw UDP port through Traefik. |
| 118 | +- Dynamic TCP/UDP host ports are also opened and closed in UFW automatically by the sync job. |
| 119 | +- If the container does not have a global IPv4 address yet, the route is skipped until it does. |
| 120 | + |
| 121 | +## Development |
| 122 | + |
| 123 | +Validate locally: |
| 124 | + |
| 125 | +```bash |
| 126 | +bun install |
| 127 | +bun run build |
| 128 | +bash -n install.sh |
| 129 | +ansible-playbook -i ansible/inventory.ini ansible/site.yml --syntax-check |
| 130 | +``` |
0 commit comments