Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 40 additions & 1 deletion Dockerfile-multigres
Original file line number Diff line number Diff line change
Expand Up @@ -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 && \
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions ansible/vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ postgres_major:

# Full version strings for each major version
postgres_release:
postgresorioledb-17: "17.6.0.072-orioledb"
postgres17: "17.6.1.115"
postgres15: "15.14.1.115"
postgresorioledb-17: "17.6.0.073-orioledb"
postgres17: "17.6.1.116"
postgres15: "15.14.1.116"

# Non Postgres Extensions
pgbouncer_release: 1.25.1
Expand Down
6 changes: 3 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion nix/packages/pgctld.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Loading