Skip to content

Commit 6905517

Browse files
committed
feat: refactored dockerfile, tests
1 parent c44ae76 commit 6905517

34 files changed

Lines changed: 13161 additions & 63 deletions

Dockerfile-multigres

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ COPY --chown=postgres:postgres ansible/files/postgresql_config/supautils.conf.j2
153153
COPY --chown=postgres:postgres ansible/files/postgresql_extension_custom_scripts /etc/postgresql-custom/extension-custom-scripts
154154
COPY --chown=postgres:postgres ansible/files/postgresql_config/custom_walg.conf /etc/postgresql-custom/wal-g.conf
155155
COPY --chown=postgres:postgres ansible/files/postgresql_config/custom_read_replica.conf /etc/postgresql-custom/read-replica.conf
156+
COPY --chown=postgres:postgres ansible/files/pgsodium_getkey_urandom.sh.j2 /usr/lib/postgresql/bin/pgsodium_getkey.sh
156157

157158
# Apply settings shared by all variants:
158159
# - enable unix socket, session preload, config includes
@@ -167,7 +168,12 @@ RUN sed -i \
167168
-e "s/ pgsodium,//g" \
168169
-e "s/db_user_namespace = off/#db_user_namespace = off/g" \
169170
/etc/postgresql/postgresql.conf && \
170-
chown -R postgres:postgres /etc/postgresql-custom
171+
echo "pgsodium.getkey_script= '/usr/lib/postgresql/bin/pgsodium_getkey.sh'" >> /etc/postgresql/postgresql.conf && \
172+
echo "vault.getkey_script= '/usr/lib/postgresql/bin/pgsodium_getkey.sh'" >> /etc/postgresql/postgresql.conf && \
173+
chown -R postgres:postgres /etc/postgresql-custom && \
174+
mkdir -p /usr/share/postgresql/extension/ && \
175+
ln -s /usr/lib/postgresql/bin/pgsodium_getkey.sh /usr/share/postgresql/extension/pgsodium_getkey && \
176+
chmod +x /usr/lib/postgresql/bin/pgsodium_getkey.sh
171177

172178
COPY migrations/db /docker-entrypoint-initdb.d/
173179
COPY ansible/files/pgbouncer_config/pgbouncer_auth_schema.sql /docker-entrypoint-initdb.d/init-scripts/00-schema.sql

nix/checks.nix

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@
107107
"5539"
108108
else if (majorVersion == "orioledb-17" && isSlim) then
109109
"5540"
110+
else if (majorVersion == "17" && isCliVariant) then
111+
"5541"
110112
else if (majorVersion == "17") then
111113
"5535"
112114
else if (majorVersion == "15") then

nix/packages/docker-image-test.nix

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ writeShellApplication {
108108
"index_advisor"
109109
)
110110
111-
# Tests to skip for multigres images (pgsodium requires getkey script not present in multigres)
111+
# Tests to skip for multigres images (pgsodium not installed; vault has z_multigres-17_ variant)
112112
MULTIGRES_SKIP_TESTS=(
113113
"pgsodium"
114114
"vault"
@@ -136,6 +136,17 @@ writeShellApplication {
136136
fi
137137
done
138138
139+
# Build list of multigres-17-specific test basenames
140+
local multigres_17_variants=()
141+
for f in "$TESTS_SQL_DIR"/z_multigres-17_*.sql; do
142+
if [[ -f "$f" ]]; then
143+
local variant_name
144+
variant_name=$(basename "$f" .sql)
145+
local base_name="''${variant_name#z_multigres-17_}"
146+
multigres_17_variants+=("$base_name")
147+
fi
148+
done
149+
139150
# Build list of multigres-orioledb-17-specific test basenames
140151
local multigres_orioledb_variants=()
141152
for f in "$TESTS_SQL_DIR"/z_multigres-orioledb-17_*.sql; do
@@ -192,7 +203,7 @@ writeShellApplication {
192203
multigres-orioledb-17) [[ "$_basename" == z_multigres-orioledb-17_* ]] && tests+=("$_basename") ;;
193204
esac
194205
else
195-
# For orioledb-like versions, use z_ variants where they exist instead of the base test
206+
# For variant versions, use z_ overrides where they exist instead of the base test
196207
if [[ "$version" == "orioledb-17" ]]; then
197208
local has_variant=false
198209
for variant in "''${orioledb_variants[@]}"; do
@@ -204,6 +215,17 @@ writeShellApplication {
204215
if [[ "$has_variant" == "false" ]]; then
205216
tests+=("$_basename")
206217
fi
218+
elif [[ "$version" == "multigres-17" ]]; then
219+
local has_variant=false
220+
for variant in "''${multigres_17_variants[@]}"; do
221+
if [[ "$_basename" == "$variant" ]]; then
222+
has_variant=true
223+
break
224+
fi
225+
done
226+
if [[ "$has_variant" == "false" ]]; then
227+
tests+=("$_basename")
228+
fi
207229
elif [[ "$version" == "multigres-orioledb-17" ]]; then
208230
local has_variant=false
209231
for variant in "''${multigres_orioledb_variants[@]}"; do
@@ -277,22 +299,21 @@ writeShellApplication {
277299
278300
log_info "Multigres: initializing PostgreSQL cluster..."
279301
docker exec -u postgres "$container" \
280-
initdb \
281-
-D /var/lib/postgresql/data \
282-
--allow-group-access \
283-
--locale-provider=icu \
284-
--encoding=UTF-8 \
285-
--icu-locale=en_US.UTF-8
302+
bash -c "echo '$POSTGRES_PASSWORD' > /tmp/pgpwfile && \
303+
initdb \
304+
-D /var/lib/postgresql/data \
305+
--username=supabase_admin \
306+
--pwfile=/tmp/pgpwfile \
307+
--allow-group-access \
308+
--locale-provider=icu \
309+
--encoding=UTF-8 \
310+
--icu-locale=en_US.UTF-8 && \
311+
rm /tmp/pgpwfile"
286312
287313
log_info "Multigres: starting PostgreSQL (config at /etc/postgresql)..."
288314
docker exec -u postgres "$container" \
289315
pg_ctl start -D /etc/postgresql -w -t 60
290316
291-
log_info "Multigres: bootstrapping supabase_admin role..."
292-
docker exec -u postgres "$container" \
293-
psql -U postgres -d postgres \
294-
-c "CREATE ROLE supabase_admin WITH SUPERUSER LOGIN PASSWORD '$POSTGRES_PASSWORD'; ALTER DATABASE postgres OWNER TO supabase_admin;"
295-
296317
log_info "Multigres: running schema migrations..."
297318
docker exec \
298319
-e POSTGRES_PASSWORD="$POSTGRES_PASSWORD" \
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
select
2+
e.evtname,
3+
e.evtowner::regrole as evtowner,
4+
n_func.nspname as evtfunction_schema,
5+
e.evtfoid::regproc as evtfunction,
6+
p.proowner::regrole as function_owner
7+
from pg_event_trigger e
8+
join pg_proc p
9+
on e.evtfoid = p.oid
10+
join pg_namespace n_func
11+
on p.pronamespace = n_func.oid
12+
where p.prorettype = 'event_trigger'::regtype;
13+
evtname | evtowner | evtfunction_schema | evtfunction | function_owner
14+
----------------------------------------+----------------+--------------------+------------------------------------+----------------
15+
issue_pg_graphql_access | supabase_admin | extensions | grant_pg_graphql_access | supabase_admin
16+
issue_graphql_placeholder | supabase_admin | extensions | set_graphql_placeholder | supabase_admin
17+
pgrst_ddl_watch | supabase_admin | extensions | pgrst_ddl_watch | supabase_admin
18+
pgrst_drop_watch | supabase_admin | extensions | pgrst_drop_watch | supabase_admin
19+
graphql_watch_ddl | supabase_admin | graphql | graphql.increment_schema_version | supabase_admin
20+
graphql_watch_drop | supabase_admin | graphql | graphql.increment_schema_version | supabase_admin
21+
issue_pg_cron_access | supabase_admin | extensions | grant_pg_cron_access | supabase_admin
22+
issue_pg_net_access | supabase_admin | extensions | grant_pg_net_access | supabase_admin
23+
pgaudit_ddl_command_end | supabase_admin | public | pgaudit_ddl_command_end | supabase_admin
24+
pgaudit_sql_drop | supabase_admin | public | pgaudit_sql_drop | supabase_admin
25+
pg_tle_event_trigger_for_drop_function | supabase_admin | pgtle | pgtle.pg_tle_feature_info_sql_drop | supabase_admin
26+
(11 rows)
27+

0 commit comments

Comments
 (0)