supabase-postgres.git / summary / log / commit / refs

commit    f2de39cbd88637a7dc0af3640e7a6ce1eece4efb
Author:   Bobbie Soedirgo <31685197+soedirgo@users.noreply.github.com>
Commit:   GitHub <noreply@github.com>
Date:     Thu May 07 06:02:25 2026 +0000

    feat(multigres): wire up init scripts & pg conf (#2137)
    
    * feat(multigres): wire up init scripts & pg conf
    
    Signed-off-by: Bobbie Soedirgo <bobbie@soedirgo.dev>
    
    * test(multigres): use PGDATA for pgctld
    
    * fix(test): start multigres pg_ctl with correct PGDATA
    
    pg_ctl needs -D pointing at the data directory, not the config dir.
    Pass /etc/postgresql/postgresql.conf via -c config_file instead.
    
    Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
    
    * chore: bump version
    
    Signed-off-by: Bobbie Soedirgo <bobbie@soedirgo.dev>
    
    ---------
    
    Signed-off-by: Bobbie Soedirgo <bobbie@soedirgo.dev>
    Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>


Dockerfile-multigres | 41 +++++++++++++++++++++++++++++++++++++- ansible/vars.yml | 6 +++--- flake.lock | 6 +++--- nix/packages/docker-image-test.nix | 8 +++++--- nix/packages/pgctld.nix | 2 +- 5 files changed, 52 insertions(+), 11 deletions(-) diff --git a/Dockerfile-multigres b/Dockerfile-multigres index b8af86c4..350887d1 100644 --- a/Dockerfile-multigres +++ b/Dockerfile-multigres @@ -145,10 +145,13 @@ RUN sed -i \ -e "s|#unix_socket_directories = '/tmp'|unix_socket_directories = '/var/run/postgresql'|g" \ -e "s|#session_preload_libraries = ''|session_preload_libraries = 'supautils'|g" \ -e "s|#include = '/etc/postgresql-custom/supautils.conf'|include = '/etc/postgresql-custom/supautils.conf'|g" \ - -e "s|#include = '/etc/postgresql-custom/wal-g.conf'|include = '/etc/postgresql-custom/wal-g.conf'|g" \ + # skip wal-g - unused by multigres + # -e "s|#include = '/etc/postgresql-custom/wal-g.conf'|include = '/etc/postgresql-custom/wal-g.conf'|g" \ -e "s/ timescaledb,//g" \ -e "s/ pgsodium,//g" \ -e "s/db_user_namespace = off/#db_user_namespace = off/g" \ + # skip - managed by pgctld + -e "s|^data_directory |#data_directory |g" \ /etc/postgresql/postgresql.conf && \ echo "pgsodium.getkey_script= '/usr/lib/postgresql/bin/pgsodium_getkey.sh'" >> /etc/postgresql/postgresql.conf && \ echo "vault.getkey_script= '/usr/lib/postgresql/bin/pgsodium_getkey.sh'" >> /etc/postgresql/postgresql.conf && \ @@ -203,6 +206,25 @@ RUN printf '#!/bin/sh\nexec /nix/var/nix/profiles/default/bin/pgctld --postgres- # Strip extensions absent from pg17 vanilla build RUN sed -i 's/ timescaledb,//g; s/ plv8,//g' /etc/postgresql-custom/supautils.conf +# Generate a single SQL manifest that pgctld runs via --init-db-sql-file after initdb. +# Creates the postgres role, runs init-scripts as postgres (matching migrate.sh), +# then runs migrations as supabase_admin. +RUN set -e && \ + manifest=/docker-entrypoint-initdb.d/multigres-init.sql && \ + printf -- "-- Auto-generated: run init-scripts and migrations after initdb\n" > "$manifest" && \ + printf "DO \$\$ BEGIN\n IF NOT EXISTS (SELECT FROM pg_roles WHERE rolname = 'postgres') THEN\n CREATE ROLE postgres SUPERUSER LOGIN;\n END IF;\nEND \$\$;\n" >> "$manifest" && \ + printf "ALTER DATABASE postgres OWNER TO postgres;\n\n" >> "$manifest" && \ + printf "SET SESSION AUTHORIZATION postgres;\n" >> "$manifest" && \ + for f in $(ls /docker-entrypoint-initdb.d/init-scripts/*.sql 2>/dev/null | sort); do \ + printf '\\ir init-scripts/%s\n' "$(basename "$f")" >> "$manifest"; \ + done && \ + printf "\nRESET SESSION AUTHORIZATION;\n\n" >> "$manifest" && \ + for f in $(ls /docker-entrypoint-initdb.d/migrations/*.sql 2>/dev/null | sort); do \ + printf '\\ir migrations/%s\n' "$(basename "$f")" >> "$manifest"; \ + done && \ + chown postgres:postgres "$manifest" + +ENV POSTGRES_INITDB_SQL_FILES=/docker-entrypoint-initdb.d/multigres-init.sql ENV PATH="/nix/var/nix/profiles/default/bin:/usr/lib/postgresql/bin:${PATH}" ENV LOCALE_ARCHIVE=/nix/var/nix/profiles/default/lib/locale/locale-archive @@ -267,6 +289,23 @@ RUN printf '#!/bin/sh\nexec /nix/var/nix/profiles/default/bin/pgctld --postgres- > /usr/local/bin/pgctld && \ chmod +x /usr/local/bin/pgctld +# Regenerate manifest after orioledb added 00-pre-init.sql to init-scripts/ +RUN set -e && \ + manifest=/docker-entrypoint-initdb.d/multigres-init.sql && \ + printf -- "-- Auto-generated: run init-scripts and migrations after initdb\n" > "$manifest" && \ + printf "DO \$\$ BEGIN\n IF NOT EXISTS (SELECT FROM pg_roles WHERE rolname = 'postgres') THEN\n CREATE ROLE postgres SUPERUSER LOGIN;\n END IF;\nEND \$\$;\n" >> "$manifest" && \ + printf "ALTER DATABASE postgres OWNER TO postgres;\n\n" >> "$manifest" && \ + printf "SET SESSION AUTHORIZATION postgres;\n" >> "$manifest" && \ + for f in $(ls /docker-entrypoint-initdb.d/init-scripts/*.sql 2>/dev/null | sort); do \ + printf '\\ir init-scripts/%s\n' "$(basename "$f")" >> "$manifest"; \ + done && \ + printf "\nRESET SESSION AUTHORIZATION;\n\n" >> "$manifest" && \ + for f in $(ls /docker-entrypoint-initdb.d/migrations/*.sql 2>/dev/null | sort); do \ + printf '\\ir migrations/%s\n' "$(basename "$f")" >> "$manifest"; \ + done && \ + chown postgres:postgres "$manifest" + +ENV POSTGRES_INITDB_SQL_FILES=/docker-entrypoint-initdb.d/multigres-init.sql ENV PATH="/nix/var/nix/profiles/default/bin:/usr/lib/postgresql/bin:${PATH}" ENV LOCALE_ARCHIVE=/nix/var/nix/profiles/default/lib/locale/locale-archive diff --git a/ansible/vars.yml b/ansible/vars.yml index 344cc0b0..24b4c90d 100644 --- a/ansible/vars.yml +++ b/ansible/vars.yml @@ -10,9 +10,9 @@ postgres_major: # Full version strings for each major version postgres_release: - postgresorioledb-17: "17.6.0.073-orioledb" - postgres17: "17.6.1.116" - postgres15: "15.14.1.116" + postgresorioledb-17: "17.6.0.074-orioledb" + postgres17: "17.6.1.117" + postgres15: "15.14.1.117" # Non Postgres Extensions pgbouncer_release: 1.25.1 diff --git a/flake.lock b/flake.lock index 1eeaee07..e5497f68 100644 --- a/flake.lock +++ b/flake.lock @@ -118,11 +118,11 @@ "multigres": { "flake": false, "locked": { - "lastModified": 1773763606, - "narHash": "sha256-ceShYR1Ocgt+glEzipF/l6Bje+sxuxDbDttaUfUAe44=", + "lastModified": 1777958128, + "narHash": "sha256-bW7Giftisi2pObfCSKoxr+yi4pINjoXdfSk3fwN3er0=", "owner": "multigres", "repo": "multigres", - "rev": "2a0b08680a95e5108bd7d33fe55c832bef3b90bb", + "rev": "7c14506b93d62b86e7ba922a90dcbf7b5574aa09", "type": "github" }, "original": { diff --git a/nix/packages/docker-image-test.nix b/nix/packages/docker-image-test.nix index 9261b2a7..5d50dee7 100644 --- a/nix/packages/docker-image-test.nix +++ b/nix/packages/docker-image-test.nix @@ -321,7 +321,7 @@ writeShellApplication { # 3. pgctld init must succeed with no extra flags (tests USER postgres fix) local init_out - init_out=$(docker exec "$container" sh -c "/usr/local/bin/pgctld init --pooler-dir $pooler_dir 2>&1") + init_out=$(docker exec -e PGDATA="$pooler_dir/pg_data" "$container" sh -c "/usr/local/bin/pgctld init --pooler-dir $pooler_dir 2>&1") if ! echo "$init_out" | grep -q "initialized successfully"; then log_error " pgctld init failed: $init_out" exit 1 @@ -330,7 +330,7 @@ writeShellApplication { # 4. pgctld start must succeed local start_out - start_out=$(docker exec "$container" sh -c "/usr/local/bin/pgctld start --pooler-dir $pooler_dir 2>&1") + start_out=$(docker exec -e PGDATA="$pooler_dir/pg_data" "$container" sh -c "/usr/local/bin/pgctld start --pooler-dir $pooler_dir 2>&1") if ! echo "$start_out" | grep -q "started successfully"; then log_error " pgctld start failed: $start_out" exit 1 @@ -398,7 +398,9 @@ writeShellApplication { log_info "Multigres: starting PostgreSQL (config at /etc/postgresql)..." docker exec -u postgres "$container" \ - pg_ctl start -D /etc/postgresql -w -t 60 + pg_ctl start -D /var/lib/postgresql/data \ + -o "-c config_file=/etc/postgresql/postgresql.conf" \ + -w -t 60 log_info "Multigres: running schema migrations..." docker exec \ diff --git a/nix/packages/pgctld.nix b/nix/packages/pgctld.nix index 4dd04670..2e66d97c 100644 --- a/nix/packages/pgctld.nix +++ b/nix/packages/pgctld.nix @@ -17,7 +17,7 @@ buildGoModule { ''; # Tests require a running PostgreSQL instance (integration tests); skip in sandbox. doCheck = false; - vendorHash = "sha256-cqSd6Dv0WYOVwg7AE1tZPh9uzsjDG32gF6eJzARsHo8="; + vendorHash = "sha256-P+B5fDlCdL0gxUa96BXz+1D0+6RSlul8eMv7iEI3Lpo="; meta = { description = "PostgreSQL control daemon for Multigres cluster lifecycle management"; [parent: 79147074eb32]