Skip to content

One-click VM image for Trinity deployment (GCP + Hetzner) #835

Open

Description

@vybe

Summary

Package Trinity as a pre-baked VM image that operators can launch on Google Cloud Platform or Hetzner with a single click — no SSH setup, no manual installation, no deployment scripts. The image has Trinity fully installed and starts automatically on first boot after minimal per-instance configuration.

Context

Today, deploying Trinity requires provisioning a VM, installing Docker, cloning the repo, configuring .env, and running ./scripts/deploy/start.sh. This is a reasonable one-time process for technical operators but a significant barrier for new users and makes fleet-scale provisioning slow.

A pre-baked image eliminates all of that. The operator launches the image from their cloud provider's UI or CLI, supplies a few environment variables (admin password, domain, Cloudflare token) via cloud-init user-data, and Trinity is running within minutes.

GCP is the current production hosting environment. Hetzner is a popular choice for self-hosted deployments given its cost/performance ratio.

Acceptance Criteria

  • Packer template at infra/packer/trinity.pkr.hcl builds a Ubuntu 22.04 base image with Trinity pre-installed
  • Image includes: Docker Engine, Docker Compose v2, Trinity cloned to /opt/trinity, cloudflared binary
  • Packer build targets: GCP custom image (via googlecompute builder) and Hetzner snapshot (via hcloud builder)
  • cloud-init first-boot script handles per-instance configuration from user-data: admin password, domain name, Cloudflare Tunnel token, email whitelist seed
  • Trinity systemd service starts automatically on boot and restarts on failure
  • .env.example pre-populated in the image; cloud-init merges user-supplied values and calls ./scripts/deploy/start.sh
  • GCP image published as a public image (or shared image family) so users can launch without building it themselves
  • infra/packer/README.md documents: how to build the image, how to launch on GCP and Hetzner, what user-data fields are accepted
  • Optionally: a minimal Terraform module (infra/terraform/) for one-command provisioning (VM + firewall rules + Cloudflare DNS)

Technical Notes

Packer builder targets:

  • GCP: googlecompute builder → produces a named image in a GCP project; can be made public via IAM allAuthenticatedUsers:roles/compute.imageUser
  • Hetzner: hcloud builder → produces a snapshot that can be shared or used as a private base

First-boot flow:

  1. cloud-init writes /opt/trinity/.env from user-data variables
  2. Systemd trinity.service calls /opt/trinity/scripts/deploy/start.sh on boot
  3. Cloudflare Tunnel auto-registers if CF_TUNNEL_TOKEN is present in user-data; otherwise Trinity is reachable only via the VM's public IP on port 80

Security: the image must not bake in any credentials. All secrets (admin password, API keys, Cloudflare token) must come from cloud-init user-data at launch time. The image should ship with a randomized placeholder SECRET_KEY that cloud-init overwrites.

Relationship to existing scripts: scripts/deploy/start.sh and scripts/deploy/stop.sh remain the canonical entrypoints — the image just pre-positions everything so those scripts can run without prerequisites.

Cloudflare Tunnel is already wired into the production docker-compose.yml. The image just needs cloudflared pre-installed; the Tunnel token is supplied at launch time.

Activity

  1. added
    priority-p3
    type-feature
    on May 13, 2026
  2. added
    theme-infrastructure
    on Jun 3, 2026
  3. added
    complexity-high
    status-incubating
    status-ready
    priority-p2
    and removed
    status-incubating
    priority-p3
    on Jun 12, 2026
  4. obasilakis commented on Sep 11, 2026

    @obasilakis
    Contributor

    These ACs are stale — the work shrank a lot (survey, 2026-09-11)

    This issue was written before #2280 and #2281. Two of its acceptance criteria now describe a shape we deliberately moved away from, and the rest is mostly already written:

    Stale as written

    • "Trinity cloned to /opt/trinity" plus an on-host build is exactly what feat: prebuilt images + pull-only hosted compose + unattended cloud-init first boot — the gate for every one-click / marketplace channel #2280 replaced. The image should bake the prebuilt GHCR images instead — packer/digitalocean/scripts/01-provision.sh pulls all five plus the third-party ones so first boot pulls nothing.
    • "Ubuntu 22.04" — the DO bundle is on 24.04.
    • infra/packer/trinity.pkr.hcl — the tree that actually exists is packer/digitalocean/ (trinity.pkr.hcl, scripts/, files/). A GCP and a Hetzner builder are additional source blocks over the same files/ tree, not a second image definition; keeping them in packer/ alongside DO is the cheaper shape.

    Already done elsewhere, reusable as-is

    The first-boot flow this issue specifies — write .env from user-data, start on boot, optional Cloudflare Tunnel, no baked credentials — is implemented in packer/digitalocean/files/opt/trinity-firstboot/firstboot.sh (230 lines). Provider-coupled points are the metadata endpoint (line 87), the baked-tag read (line 94), TRINITY_INSTALL_SOURCE (line 131) and the cloud-init hook path; everything else carries over. The reuse map on #2282 applies here unchanged.

    Note that firstboot.sh goes further than this issue asks: it applies DOCKER-USER DROP rules (the Docker-past-ufw gap), and it issues and verifies a Let's Encrypt certificate for the bare IP. Do not drop either when porting — the certificate verification exists because the failure is otherwise silent.

    The one real blocker, and it is on #2280

    The GHCR images are amd64 only today — every manifest index carries amd64 plus an unknown attestation entry and no arm64 (check on #2280). Hetzner's CAX line is arm64, so the Hetzner half of this issue needs #2280's multi-arch AC done first, or it ships amd64-only and silently excludes the cheapest Hetzner plans. The GCP half is unaffected.

    Scope question worth answering before picking this up

    Hetzner has no third-party marketplace, so the deliverable there is a shared snapshot plus documentation, not a listing — materially less reach than DigitalOcean (#2281), Vultr (#2282) or the community buttons (#2283). GCP public-image sharing needs the allAuthenticatedUsers:roles/compute.imageUser grant and an owning project. Both are fine, but this issue is now the lowest-reach item in epic #2332 rather than a peer of the marketplace lanes; worth re-ranking rather than working in filed order.

  5. obasilakis commented on Oct 1, 2026

    @obasilakis
    Contributor

    Database backend: PostgreSQL. SQLite reached end-of-support on 2026-09-01 (#1278). New installs from any one-click channel must start on PostgreSQL.

    Added acceptance criteria:

    The Packer, Ubuntu-version and cloudflared criteria above predate the shared hosted path (#2280, packer/digitalocean, packer/aws). They need re-scoping against it before work starts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    complexity-highpriority-p2status-readytheme-infrastructuretype-feature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions