Skip to content

feat(cli): add SUPABASE_USE_SLIM_IMAGES flag for slim ghcr images - #6329

Open
avallete wants to merge 7 commits into
developfrom
avallete/supabase-slim-images-flag-c95c16
Open

feat(cli): add SUPABASE_USE_SLIM_IMAGES flag for slim ghcr images#6329
avallete wants to merge 7 commits into
developfrom
avallete/supabase-slim-images-flag-c95c16

Conversation

@avallete

@avallete avallete commented Aug 25, 2026

Copy link
Copy Markdown
Member

Summary

Adds an opt-in env feature flag SUPABASE_USE_SLIM_IMAGES ("true" or "1", read from the ambient process env per call) that makes the legacy shell resolve its local-stack Docker images from the slim ghcr.io/supabase/cli/<service> builds instead of the docker.io images pinned in the embedded Dockerfile manifest — so the slim images can be exercised through the stable CLI. With the flag unset, behavior is byte-identical.

Commit 1 — flag plumbing

  • apps/cli/src/shared/services/slim-images.ts owns the gate and the pure translation: Dockerfile alias → stack-catalog service, keeping the Dockerfile's pinned version translated into the slim tag scheme via dockerImageForService from a new lightweight @supabase/stack/versions export (supavisor:2.9.7pooler:v2.9.7, logflare:1.50.4analytics:v1.50.4, vector's docker.io-only -alpine suffix stripped).
  • dockerfileServiceImage(alias) is the single flag-translated choke point for default images; dockerfileServiceImageRaw remains for identity contracts. Pinned-version paths (legacyResolvePinnedImage, services listings, gen types) go through the catalog so tag-scheme differences normalize correctly.
  • Slim refs bypass the SUPABASE_INTERNAL_IMAGE_REGISTRY/ECR mirror rewrite entirely (single pull candidate) — they are published only at ghcr.io/supabase/cli, so any rewrite would silently pull the non-slim mirror.

Commit 2 — slim postgres container support (start + shadow)

The slim postgres image has a different runtime contract from docker.io (non-root uid 65532, its own entry.sh, postgres under /opt/postgres, no docker-entrypoint.sh). When the resolved ref is slim, the main-db and shadow-db specs switch to it:

  • The image entrypoint is kept — entry.sh self-initializes on first boot (initdb, config, bundled supabase migrations) and passes container argv through to postgres, so [db.settings] travel as -c key=value argv pairs.
  • The CLI's bootstrap schema (schema.sql + webhook.sql + _supabase.sql) and the deterministic pgsodium root key are staged via the existing secret-file docker cp; the image's bundled migrate.sh executes /etc/postgresql.schema.sql as its first-boot postinit — the same hook the docker.io image runs — giving exactly-once semantics across container restarts with no CLI-side marker. PGSODIUM_KEY_FILE points the image's getkey script at the CLI's root key.
  • start --from-backup refuses a slim resolved ref with a typed, classified error until the restore flow learns the slim contract (a registry override landing back on docker.io still restores).
  • Verified against a real slim db start: healthy container, settings applied via argv, all three schema templates present exactly once across restarts, root key loaded, shadow spec exercised by hand.

Deliberately unchanged even with the flag on

  • kong and the differ/migra/pgprove job images (no slim builds)
  • pg 13/14/15 major-version fallback images and OrioleDB overrides
  • the deno_version = 1 edge-runtime image (supabase/edge-runtime:v1.68.4)
  • status/--exclude short names and services image overrides

Reviewer notes

  • The flag reads the ambient process env only — values set solely in supabase/.env are not honored. SIDE_EFFECTS.md rows were added for every command whose image resolution the flag reaches.
  • The shared choke point also affects the functions deploy/download/serve Docker paths in both shells; intentional for an opt-in flag.
  • Known image-side gap (not a CLI defect): the slim postgres image ships empty supautils.* GUCs, so create extension pg_net fails — this blocks db diff/declarative shadow flows and start with [experimental.webhooks] enabled until slim-services fixes its postgresql.conf template allowlist.

Linked issue

Closes #

  • The linked issue is open and carries the open-for-contribution label (or I'm a Supabase maintainer).

Checklist

  • The PR title follows Conventional Commits (e.g. fix(cli): …).
  • Tests added or updated for the change.
  • pnpm check:all and pnpm test pass for the workspace(s) I touched.

🤖 Generated with Claude Code

When SUPABASE_USE_SLIM_IMAGES is "true" or "1", the legacy shell resolves
its local-stack Docker images from the slim ghcr.io/supabase/cli/<service>
builds instead of the docker.io images pinned in the embedded Dockerfile
manifest, keeping the Dockerfile version pins translated into the slim tag
scheme via @supabase/stack's catalog (new "./versions" package export).

Services with no slim build keep their docker.io reference: kong, the
differ/migra/pgprove job images, the pg 13/14/15 major-version fallbacks,
OrioleDB overrides, and the deno_version = 1 edge-runtime pin. Slim refs
bypass the SUPABASE_INTERNAL_IMAGE_REGISTRY/ECR rewrite (they exist only at
ghcr.io/supabase/cli), status/--exclude short names stay flag-invariant,
services-command image overrides are never translated, and the declarative
stale-container guard now rejects slim/non-slim family mismatches. With the
flag unset, behavior is byte-identical.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@avallete
avallete requested a review from a team as a code owner August 25, 2026 16:51

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 92576b1233

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/cli/src/shared/services/slim-images.ts
@github-actions

github-actions Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Supabase CLI preview

npx --yes https://pkg.pr.new/supabase/cli/supabase@c030668ec95c5fdbcabffa9f3fed40be9cdbcff3

Preview package for commit c030668.

With SUPABASE_USE_SLIM_IMAGES on and a resolved ghcr.io/supabase/cli/postgres
ref, the main-db and shadow-db container specs switch to the slim image's
contract: the image entrypoint is kept (entry.sh self-initializes and passes
container argv through to postgres), config.toml db settings travel as -c
argv pairs, and the CLI's bootstrap schema plus pgsodium root key are staged
via the existing secret-file docker cp — the image's bundled migrate.sh runs
/etc/postgresql.schema.sql as its first-boot postinit, giving exactly-once
semantics without any CLI-side marker. PGSODIUM_KEY_FILE keeps the root key
deterministic for the non-root (uid 65532) image user.

start --from-backup refuses a slim resolved ref with a typed error until the
restore flow learns the slim contract. Flag off (or a registry override
landing on docker.io) stays byte-identical.

Verified against a real slim db start: healthy container, settings applied,
all three schema templates present exactly once across restarts, root key
loaded, shadow spec exercised. Shadow flows additionally need a slim-services
image fix (empty supautils GUCs block "create extension pg_net").

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: efba3aa535

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/cli/src/shared/services/dockerfile-images.ts
Comment thread apps/cli/src/legacy/shared/db-bootstrap/postgres.service.ts
…slim-images-flag-c95c16

# Conflicts:
#	apps/cli/src/legacy/commands/start/SIDE_EFFECTS.md
#	apps/cli/src/legacy/shared/db-bootstrap/postgres.service.unit.test.ts

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cbb49da949

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/cli/src/shared/functions/functions.shared.ts
Reusing a named database volume initialized by the docker.io postgres image
under SUPABASE_USE_SLIM_IMAGES crash-loops the slim image's non-root user
against the 700-mode PGDATA until the health check times out. Before creating
the container on an existing volume, a cheap docker-run probe now checks that
the slim image's own user can read PG_VERSION and fails fast with remediation
(stop --no-backup to reset, or unset the flag) when it cannot.

Also documents the flag in the SIDE_EFFECTS of db pull, services, and the
declarative schema commands, and records why the deno1 edge-runtime tag check
intentionally also covers an explicit pin of that tag.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 429bad2c79

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/cli/src/legacy/shared/db-bootstrap/postgres.service.ts
Comment thread apps/cli/src/legacy/shared/db-bootstrap/postgres.service.ts Outdated
Comment thread apps/cli/src/shared/services/slim-images.ts
…slim contract

The slim entrypoint runs a temporary server during first-boot init, so the
slim specs' healthcheck now requires PID 1 to be the final postgres process
before pg_isready counts (same gate the stack's docker path uses); docker.io
keeps the plain pg_isready test byte-identically. The pg_dump one-shot runner
(db dump, db pull, migration squash) now overrides the entrypoint to bash on
slim refs — the slim entrypoint would otherwise initdb an empty cluster and
hand the dump command to postgres. Also rewords a settings-renderer comment
off Go-authority framing.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 89b4e15a33

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/cli/src/legacy/commands/db/start/start.integration.test.ts Outdated
Comment thread apps/cli/src/legacy/shared/db-bootstrap/container-lifecycle.ts Outdated
…t coupling

Postgres must write postmaster.pid and WAL under PGDATA, so the reused-volume
guard now also requires write access (test -w on the mount) — a read-only-
accessible volume previously slipped past the guard into the same crash-loop
it exists to prevent. The error and probe naming follow (Inaccessible /
AccessibleToImage). The new integration tests narrow errors with instanceof
on the exported classes instead of asserting the _tag field through casts.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 235924d28f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/cli/src/legacy/shared/legacy-edge-runtime-image.ts Outdated
…y resolver

The legacy resolver and the functions-path edgeRuntimeImage read the same
.temp/edge-runtime-version pin but disagreed under the slim flag: a stale
v1.68.4 pin (left by an earlier deno_version = 1 run) tag-swapped onto the
slim base yields an unpullable ref, since no slim build of that tag exists.
Both resolvers now apply the same docker.io exception from one shared
constant.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

1 participant