Skip to content

fix: make local Supabase build-from-source work on Alpine bases#61

Merged
andinux merged 2 commits into
mainfrom
fix/supabase-build-from-source-alpine
Jul 27, 2026
Merged

fix: make local Supabase build-from-source work on Alpine bases#61
andinux merged 2 commits into
mainfrom
fix/supabase-build-from-source-alpine

Conversation

@andinux

@andinux andinux commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

Closes #60.

The local build-from-source path (make postgres-supabase-build, docker/postgresql/Dockerfile.supabase) assumed an Ubuntu-userland Supabase base: it installed its toolchain with apt-get and hardcoded the Ubuntu-only pg_config path, so it broke as soon as the Supabase CLI bundled an Alpine-based Postgres image (PG17 17.6.1.084+). #58 fixed the published release image; this is the deferred counterpart.

Approach

Both Supabase base families run a Nix-built, glibc-linked PostgreSQL (verified: the server binary's ELF interpreter is the Nix store's ld-linux, with versioned GLIBC_* symbols — Alpine/musl is only the surrounding userland). So instead of porting apk/apt toolchain detection into the build, the extension is now compiled in a dedicated glibc builder stage:

  • Builder: FROM postgres:${PG_MAJOR} (Debian) with build-essential + postgresql-server-dev-${PG_MAJOR} from the preconfigured PGDG repo — the same toolchain family that produces the release artifacts. This yields a glibc .so matching the glibc Postgres on either base, rather than a musl-compiled one that drags a second libc into the server process.
  • Runtime: resolves pg_config by probing the Nix profiles then PATH (ported from Dockerfile.supabase.release) and no longer needs a compiler or package manager, so the base userland is irrelevant.
  • Makefile: postgres-supabase-build derives PG_MAJOR from the resolved base image tag (default 17), so auto-detection from a running Supabase CLI stack picks matching builder headers for PG15 vs PG17.

Verification

make postgres-supabase-build SUPABASE_POSTGRES_TAG=<tag> followed by CREATE EXTENSION cloudsync; SELECT cloudsync_version(); (as supabase_admin) returns 1.1.2 on:

  • 17.6.1.151 (Alpine)
  • 17.6.1.071 (Ubuntu, PG17)
  • 15.8.1.135 (Ubuntu, PG15 — also exercises the non-17 PG_MAJOR derivation)

The installed cloudsync.so in the Alpine image references versioned GLIBC_* symbols, confirming the matched-libc artifact.

🤖 Generated with Claude Code

andinux and others added 2 commits July 27, 2026 11:19
Compile the extension in a dedicated glibc builder stage (official
postgres:<major> image with PGDG headers, the same toolchain that builds
the release artifacts) instead of installing an apt toolchain into the
Supabase base, and resolve pg_config in the runtime stage by probing the
Nix profile paths instead of hardcoding the Ubuntu-only location. The
runtime stage no longer needs a compiler or package manager, so the
Ubuntu/Alpine userland difference stops mattering; both families run a
Nix-built, glibc-linked PostgreSQL, so the same .so serves both.

postgres-supabase-build derives the builder's PG major version from the
resolved base image tag, so auto-detection from a running Supabase CLI
stack picks matching headers for PG15 vs PG17.

Verified: CREATE EXTENSION cloudsync + cloudsync_version() on Alpine
17.6.1.151 and Ubuntu 17.6.1.071 / 15.8.1.135.

Closes #60

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The targets are postgres-supabase-run-test / postgres-docker-run-test,
but .PHONY and the help text advertised *-run-smoke-test, which does not
exist.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@andinux
andinux merged commit 0e4be01 into main Jul 27, 2026
33 checks passed
@andinux
andinux deleted the fix/supabase-build-from-source-alpine branch July 27, 2026 10:08
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.

Local build-from-source (Dockerfile.supabase) assumes an Ubuntu Supabase base

1 participant