feat(selfhost): compose stack and end-to-end check

WC
2d ago
+771-12

Summary (AI generated)

A Docker Compose stack for self-hosted Capgo on one domain, plus an end-to-end check that runs it in CI.

  • selfhost/compose.yml: only the proxy is published (80, 443).

    ServiceImage
    proxybuilt from selfhost/capgo-proxy/Dockerfile (Caddy: console, /api, /plugin, /files, /auth/v1)
    workersbuilt from selfhost/capgo-workers/Dockerfile: api, plugin, files
    authour GoTrue fork, built from cloudflare_workers/gotrue/Dockerfile, as gotrue_cf on auth_cf like Cloud
    storagerustfs/rustfs:1.0.7 (public image)
    dbsupabase/postgres:17.6.1.143 (public image)
    setup-db, setupbuilt from selfhost/capgo-setup/Dockerfile, before and after GoTrue

    No published images (Martin's decision): Capgo's four images are built from this checkout with docker compose --env-file .env up -d --build. The ghcr publishing workflows are removed in separate PRs, not here.

    Start order: db -> setup-db -> auth -> setup -> db-settings -> workers -> proxy. setup-db runs on every up and sets gotrue_cf's password from GOTRUE_DB_PASSWORD, so changing it in .env and running docker compose up -d changes it (auth is recreated with the new value). setup writes the install data (settings, the Solo plan, the RBAC catalog). storage-init creates the two buckets; db-settings routes queue wakeups to the Workers.

  • selfhost/.env.example: every variable, secrets as placeholders.

  • selfhost/test/e2e.sh + e2e-flow.ts, run by .github/workflows/selfhost_e2e.yml: builds the images with docker compose build, starts the stack with generated secrets and no seed, then signs up, signs in through /auth/v1, creates an organization and an API key, adds an app and uploads a bundle with the CLI (TUS), makes the channel default, checks /updates returns the bundle and that it downloads. Last, it changes GOTRUE_DB_PASSWORD, runs up -d again, signs in again, and checks the old database password is refused.

  • selfhost/capgo-setup/test/two-phase.sh: also checks that setup-db applies a changed GOTRUE_DB_PASSWORD.

Motivation (AI generated)

Self-hosters need one file to start Capgo. The images exist (capgo-proxy, capgo-workers, capgo-setup); this puts them together and proves the main journey works on a fresh database.

Business impact (AI generated)

First runnable self-host stack. Nothing changes for Capgo Cloud: only files under selfhost/ and a new workflow.

Known gaps (AI generated)

  • Trial ends after 15 days. New organizations get Cloud's 15-day trial; after it, is_paying_and_good_plan_org is false (no Stripe subscription) and uploads are refused. Not wired here on purpose (NEW_ORG_TRIAL_DAYS, Cap-go/capgo.app#4362, is not merging for now). Workaround: UPDATE public.stripe_info SET trial_at = now() + interval '100 years';.
  • Uploads only with TUS (--tus): the S3 server is internal, so presigned uploads cannot reach it.
  • The CLI refuses plain HTTP unless the host is loopback, and says nothing (exits 1). The check points the CLI at 127.0.0.1.
  • Not checked: HTTPS on a real domain (ACME), queue wakeups and email end to end, the console in a browser.

Test plan (AI generated)

  • Self-host end-to-end job passes on the head
  • selfhost/capgo-setup/test/two-phase.sh with the password step, locally
  • docker compose config validates with .env.example

Generated with AI

Summary by CodeRabbit

  • New Features
    • Added a self-hosted deployment option that brings the services needed to run the app together behind a single domain.
    • Added an example environment file covering required credentials and optional settings, with guidance on configuring the domain, email, and CAPTCHA options.
    • Self-hosted deployments can apply a database password change and continue authenticating with the updated password.
  • Quality
    • Added end-to-end checks for self-hosted setup, sign-in, app uploads, and plugin downloads.
    • Self-hosted checks now run automatically when relevant changes are proposed.