Skip to content

Add fat Docker image for treq Supabase server stack - #248

Draft
Ziinc wants to merge 7 commits into
mainfrom
cursor/supabase-fat-docker-dc9d
Draft

Add fat Docker image for treq Supabase server stack#248
Ziinc wants to merge 7 commits into
mainfrom
cursor/supabase-fat-docker-dc9d

Conversation

@Ziinc

@Ziinc Ziinc commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

Summary

Single-tenant self-hosted fat API image (no GoTrue) plus CI that builds and verifies it.

Image

  • Base: alpine:3.23 — PostgREST + Edge Runtime + nginx only
  • GoTrue removed — no /auth/v1
  • Default VERIFY_JWT=false
  • Postgres remains a supabase/postgres compose sidecar

CI / test

  • .github/workflows/supabase-docker.yml builds docker-compose.test.yml and runs test/verify-self-hosted.sh
  • Checks: /health, /auth/v1 absent, data API (OpenAPI, profiles, merge_queue_metrics), edge (exchange-desktop-token, merge-queue-worker, github-webhook HMAC)
make supabase.docker.test   # local equivalent

Test plan

  • make supabase.docker.test — 13/13 passed locally
  • GitHub Actions Supabase Docker workflow green on this PR
Open in Web Open in Cursor 

cursoragent and others added 2 commits August 10, 2026 14:27
Single container packs Postgres, GoTrue, PostgREST, Edge Runtime, and
nginx with treq migrations and Edge Functions baked in — useful for
local/CI self-hosting without nested multi-container supabase start.

Co-authored-by: Ziinc <Ziinc@users.noreply.github.com>
Wait for the durable postmaster after init (not the temp server),
set role passwords only for roles that exist, vendor supabase-js for
Edge Functions, and verify JWTs in the main router without JSR fetches.

Co-authored-by: Ziinc <Ziinc@users.noreply.github.com>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Boot order is the hard part: supabase/postgres init uses a temporary postmaster that also answers pg_isready.

  • Wait for 5 consecutive successful admin connections with migrate.sh not running before applying passwords/migrations — lands on the durable postmaster
  • Role passwords are set only when the role exists (supabase_functions_admin is absent in this image)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kong-compatible /functions/v1/<name> router, matching local CLI behavior for JWT:

  • HS256 verify via Web Crypto — no jsr:/esm.sh fetch at main-worker boot (this environment has no egress to those hosts)
  • github-webhook skips JWT (HMAC inside the function), same as config.toml verify_jwt = false

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Single-process fat image instead of compose: copies GoTrue/PostgREST/Edge Runtime binaries onto supabase/postgres, then supervisord + nginx front them.

  • Alpine base needs a small glibc runtime for edge-runtime
  • deno.json remaps esm.sh/@supabase/supabase-js → vendored node_modules so functions boot without registry egress
  • Build context is supabase/ only (see .dockerignore)

cursoragent and others added 4 commits August 10, 2026 14:46
Co-authored-by: Ziinc <Ziinc@users.noreply.github.com>
Base the API image on alpine:3.23 and layer GoTrue, PostgREST, Edge
Runtime, and nginx incrementally. supabase/postgres runs as a separate
compose service; prepare-network.sh fixes nested-Docker bridge TCP.

Co-authored-by: Ziinc <Ziinc@users.noreply.github.com>
Co-authored-by: Ziinc <Ziinc@users.noreply.github.com>
Co-authored-by: Ziinc <Ziinc@users.noreply.github.com>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Base is now alpine:3.23 — Postgres is not in this image.

  • Layers are additive: apk packages → GoTrue → PostgREST → Edge Runtime (+glibc) → treq app → vendored supabase-js
  • Compose runs supabase/postgres as db; entrypoint waits on PGHOST

Drop GoTrue from the Alpine API image for self-hosted single-tenant
mode (VERIFY_JWT=false). Add docker-compose.test.yml, verify-self-hosted.sh
covering health, data APIs, and edge functions, plus a GitHub Actions
workflow to build and run that suite.

Co-authored-by: Ziinc <Ziinc@users.noreply.github.com>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Single-tenant checks against the test compose stack (service_role for data APIs; no user sessions).

  • Asserts /auth/v1 is gone
  • Data: OpenAPI, profiles, merge_queue_metrics
  • Edge: token exchange validation, worker nudge, webhook HMAC accept/reject

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI path for the fat image: compose up with --wait, then verify-self-hosted.sh.

  • Triggers on supabase/** and this workflow file
  • prepare-network.sh keeps nested-Docker / DinD bridge TCP working when needed
  • Dumps compose logs on failure; always tears down with -v

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants