Skip to content

Commit 3ae26a9

Browse files
committed
tmp
Signed-off-by: Bobbie Soedirgo <bobbie@soedirgo.dev>
1 parent d488045 commit 3ae26a9

4 files changed

Lines changed: 47 additions & 8 deletions

File tree

Dockerfile-multigres

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,13 @@ RUN sed -i \
145145
-e "s|#unix_socket_directories = '/tmp'|unix_socket_directories = '/var/run/postgresql'|g" \
146146
-e "s|#session_preload_libraries = ''|session_preload_libraries = 'supautils'|g" \
147147
-e "s|#include = '/etc/postgresql-custom/supautils.conf'|include = '/etc/postgresql-custom/supautils.conf'|g" \
148-
-e "s|#include = '/etc/postgresql-custom/wal-g.conf'|include = '/etc/postgresql-custom/wal-g.conf'|g" \
148+
# skip wal-g - unused by multigres
149+
# -e "s|#include = '/etc/postgresql-custom/wal-g.conf'|include = '/etc/postgresql-custom/wal-g.conf'|g" \
149150
-e "s/ timescaledb,//g" \
150151
-e "s/ pgsodium,//g" \
151152
-e "s/db_user_namespace = off/#db_user_namespace = off/g" \
153+
# skip - managed by pgctld
154+
-e "s|^data_directory |#data_directory |g" \
152155
/etc/postgresql/postgresql.conf && \
153156
echo "pgsodium.getkey_script= '/usr/lib/postgresql/bin/pgsodium_getkey.sh'" >> /etc/postgresql/postgresql.conf && \
154157
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-
203206
# Strip extensions absent from pg17 vanilla build
204207
RUN sed -i 's/ timescaledb,//g; s/ plv8,//g' /etc/postgresql-custom/supautils.conf
205208

209+
# Generate a single SQL manifest that pgctld runs via --init-db-sql-file after initdb.
210+
# Creates the postgres role, runs init-scripts as postgres (matching migrate.sh),
211+
# then runs migrations as supabase_admin.
212+
RUN set -e && \
213+
manifest=/docker-entrypoint-initdb.d/multigres-init.sql && \
214+
printf -- "-- Auto-generated: run init-scripts and migrations after initdb\n" > "$manifest" && \
215+
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" && \
216+
printf "ALTER DATABASE postgres OWNER TO postgres;\n\n" >> "$manifest" && \
217+
printf "SET SESSION AUTHORIZATION postgres;\n" >> "$manifest" && \
218+
for f in $(ls /docker-entrypoint-initdb.d/init-scripts/*.sql 2>/dev/null | sort); do \
219+
printf '\\ir init-scripts/%s\n' "$(basename "$f")" >> "$manifest"; \
220+
done && \
221+
printf "\nRESET SESSION AUTHORIZATION;\n\n" >> "$manifest" && \
222+
for f in $(ls /docker-entrypoint-initdb.d/migrations/*.sql 2>/dev/null | sort); do \
223+
printf '\\ir migrations/%s\n' "$(basename "$f")" >> "$manifest"; \
224+
done && \
225+
chown postgres:postgres "$manifest"
226+
227+
ENV POSTGRES_INITDB_SQL_FILES=/docker-entrypoint-initdb.d/multigres-init.sql
206228
ENV PATH="/nix/var/nix/profiles/default/bin:/usr/lib/postgresql/bin:${PATH}"
207229
ENV LOCALE_ARCHIVE=/nix/var/nix/profiles/default/lib/locale/locale-archive
208230

@@ -267,6 +289,23 @@ RUN printf '#!/bin/sh\nexec /nix/var/nix/profiles/default/bin/pgctld --postgres-
267289
> /usr/local/bin/pgctld && \
268290
chmod +x /usr/local/bin/pgctld
269291

292+
# Regenerate manifest after orioledb added 00-pre-init.sql to init-scripts/
293+
RUN set -e && \
294+
manifest=/docker-entrypoint-initdb.d/multigres-init.sql && \
295+
printf -- "-- Auto-generated: run init-scripts and migrations after initdb\n" > "$manifest" && \
296+
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" && \
297+
printf "ALTER DATABASE postgres OWNER TO postgres;\n\n" >> "$manifest" && \
298+
printf "SET SESSION AUTHORIZATION postgres;\n" >> "$manifest" && \
299+
for f in $(ls /docker-entrypoint-initdb.d/init-scripts/*.sql 2>/dev/null | sort); do \
300+
printf '\\ir init-scripts/%s\n' "$(basename "$f")" >> "$manifest"; \
301+
done && \
302+
printf "\nRESET SESSION AUTHORIZATION;\n\n" >> "$manifest" && \
303+
for f in $(ls /docker-entrypoint-initdb.d/migrations/*.sql 2>/dev/null | sort); do \
304+
printf '\\ir migrations/%s\n' "$(basename "$f")" >> "$manifest"; \
305+
done && \
306+
chown postgres:postgres "$manifest"
307+
308+
ENV POSTGRES_INITDB_SQL_FILES=/docker-entrypoint-initdb.d/multigres-init.sql
270309
ENV PATH="/nix/var/nix/profiles/default/bin:/usr/lib/postgresql/bin:${PATH}"
271310
ENV LOCALE_ARCHIVE=/nix/var/nix/profiles/default/lib/locale/locale-archive
272311

ansible/vars.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ postgres_major:
1010

1111
# Full version strings for each major version
1212
postgres_release:
13-
postgresorioledb-17: "17.6.0.071"
14-
postgres17: "17.6.1.114"
15-
postgres15: "15.14.1.114"
13+
postgresorioledb-17: "17.6.0.071-orioledb-mg-1"
14+
postgres17: "17.6.1.114-mg-1"
15+
postgres15: "15.14.1.114-mg-1"
1616

1717
# Non Postgres Extensions
1818
pgbouncer_release: 1.25.1

flake.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

nix/packages/pgctld.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ buildGoModule {
1717
'';
1818
# Tests require a running PostgreSQL instance (integration tests); skip in sandbox.
1919
doCheck = false;
20-
vendorHash = "sha256-cqSd6Dv0WYOVwg7AE1tZPh9uzsjDG32gF6eJzARsHo8=";
20+
vendorHash = "sha256-Vf30HAfKRCuMbX7H9PfmZhmbOt7SJ7AHbsX7ND61/0M=";
2121

2222
meta = {
2323
description = "PostgreSQL control daemon for Multigres cluster lifecycle management";

0 commit comments

Comments
 (0)