fix: make local Supabase build-from-source work on Alpine bases#61
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 withapt-getand hardcoded the Ubuntu-onlypg_configpath, so it broke as soon as the Supabase CLI bundled an Alpine-based Postgres image (PG1717.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 versionedGLIBC_*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:FROM postgres:${PG_MAJOR}(Debian) withbuild-essential+postgresql-server-dev-${PG_MAJOR}from the preconfigured PGDG repo — the same toolchain family that produces the release artifacts. This yields a glibc.somatching the glibc Postgres on either base, rather than a musl-compiled one that drags a second libc into the server process.pg_configby probing the Nix profiles then PATH (ported fromDockerfile.supabase.release) and no longer needs a compiler or package manager, so the base userland is irrelevant.postgres-supabase-buildderivesPG_MAJORfrom 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 byCREATE EXTENSION cloudsync; SELECT cloudsync_version();(assupabase_admin) returns1.1.2on:17.6.1.151(Alpine)17.6.1.071(Ubuntu, PG17)15.8.1.135(Ubuntu, PG15 — also exercises the non-17PG_MAJORderivation)The installed
cloudsync.soin the Alpine image references versionedGLIBC_*symbols, confirming the matched-libc artifact.🤖 Generated with Claude Code