Skip to content

Commit 52deb6f

Browse files
jfrochesamrose
andauthored
feat: support multiple versions of the pgroonga extension (supabase#1677)
* feat: support multiple versions of the pgroonga extension Build multiple versions of the pgroonga extension on different PostgreSQL versions. Add test for the extensions and their upgrade on PostgreSQL 15 and 17. * refactor(nix): make sure ext contains only extensions Moved sfcgal and mecab-naist-jdic from nix/ext to nix/packages. * feat: resolve a few issues with tests and integration with tooling * fix: make sure that docker image has full/correct groonga/pgroonga handling * chore: bump version to release --------- Co-authored-by: Sam Rose <samuel@supabase.io>
1 parent 13fb638 commit 52deb6f

25 files changed

+576
-166
lines changed

Dockerfile-15

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,20 @@ RUN nix profile install .#wal-g-3 && \
122122

123123
RUN nix store gc
124124

125+
WORKDIR /
126+
####################
127+
# setup-groonga
128+
####################
129+
FROM base as groonga
130+
131+
WORKDIR /nixpg
132+
133+
RUN nix profile install .#supabase-groonga && \
134+
mkdir -p /tmp/groonga-plugins && \
135+
cp -r /nix/var/nix/profiles/default/lib/groonga/plugins /tmp/groonga-plugins/
136+
137+
RUN nix store gc
138+
125139
WORKDIR /
126140
# ####################
127141
# # Download gosu for easy step-down from root
@@ -153,6 +167,7 @@ FROM gosu as production
153167
RUN id postgres || (echo "postgres user does not exist" && exit 1)
154168
# # Setup extensions
155169
COPY --from=walg /tmp/wal-g /usr/local/bin/
170+
COPY --from=groonga /tmp/groonga-plugins/plugins /usr/lib/groonga/plugins
156171

157172
# # Initialise configs
158173
COPY --chown=postgres:postgres ansible/files/postgresql_config/postgresql.conf.j2 /etc/postgresql/postgresql.conf
@@ -216,4 +231,7 @@ ENV LOCALE_ARCHIVE /usr/lib/locale/locale-archive
216231
RUN mkdir -p /usr/share/postgresql/extension/ && \
217232
ln -s /usr/lib/postgresql/bin/pgsodium_getkey.sh /usr/share/postgresql/extension/pgsodium_getkey && \
218233
chmod +x /usr/lib/postgresql/bin/pgsodium_getkey.sh
234+
235+
ENV GRN_PLUGINS_DIR=/usr/lib/groonga/plugins
236+
219237
CMD ["postgres", "-D", "/etc/postgresql"]

Dockerfile-17

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,20 @@ RUN nix profile install .#wal-g-3 && \
126126

127127
RUN nix store gc
128128

129+
WORKDIR /
130+
####################
131+
# setup-groonga
132+
####################
133+
FROM base as groonga
134+
135+
WORKDIR /nixpg
136+
137+
RUN nix profile install .#supabase-groonga && \
138+
mkdir -p /tmp/groonga-plugins && \
139+
cp -r /nix/var/nix/profiles/default/lib/groonga/plugins /tmp/groonga-plugins/
140+
141+
RUN nix store gc
142+
129143
WORKDIR /
130144
# ####################
131145
# # Download gosu for easy step-down from root
@@ -157,6 +171,7 @@ FROM gosu as production
157171
RUN id postgres || (echo "postgres user does not exist" && exit 1)
158172
# # Setup extensions
159173
COPY --from=walg /tmp/wal-g /usr/local/bin/
174+
COPY --from=groonga /tmp/groonga-plugins/plugins /usr/lib/groonga/plugins
160175

161176
# # Initialise configs
162177
COPY --chown=postgres:postgres ansible/files/postgresql_config/postgresql.conf.j2 /etc/postgresql/postgresql.conf
@@ -229,4 +244,7 @@ ENV LOCALE_ARCHIVE /usr/lib/locale/locale-archive
229244
RUN mkdir -p /usr/share/postgresql/extension/ && \
230245
ln -s /usr/lib/postgresql/bin/pgsodium_getkey.sh /usr/share/postgresql/extension/pgsodium_getkey && \
231246
chmod +x /usr/lib/postgresql/bin/pgsodium_getkey.sh
247+
248+
ENV GRN_PLUGINS_DIR=/usr/lib/groonga/plugins
249+
232250
CMD ["postgres", "-D", "/etc/postgresql"]

Dockerfile-orioledb-17

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,20 @@ RUN nix profile install .#wal-g-3 && \
126126

127127
RUN nix store gc
128128

129+
WORKDIR /
130+
####################
131+
# setup-groonga
132+
####################
133+
FROM base as groonga
134+
135+
WORKDIR /nixpg
136+
137+
RUN nix profile install .#supabase-groonga && \
138+
mkdir -p /tmp/groonga-plugins && \
139+
cp -r /nix/var/nix/profiles/default/lib/groonga/plugins /tmp/groonga-plugins/
140+
141+
RUN nix store gc
142+
129143
WORKDIR /
130144
# ####################
131145
# # Download gosu for easy step-down from root
@@ -157,6 +171,7 @@ FROM gosu as production
157171
RUN id postgres || (echo "postgres user does not exist" && exit 1)
158172
# # Setup extensions
159173
COPY --from=walg /tmp/wal-g /usr/local/bin/
174+
COPY --from=groonga /tmp/groonga-plugins/plugins /usr/lib/groonga/plugins
160175

161176
# # Initialise configs
162177
COPY --chown=postgres:postgres ansible/files/postgresql_config/postgresql.conf.j2 /etc/postgresql/postgresql.conf
@@ -235,4 +250,6 @@ RUN mkdir -p /usr/share/postgresql/extension/ && \
235250
ln -s /usr/lib/postgresql/bin/pgsodium_getkey.sh /usr/share/postgresql/extension/pgsodium_getkey && \
236251
chmod +x /usr/lib/postgresql/bin/pgsodium_getkey.sh
237252

253+
ENV GRN_PLUGINS_DIR=/usr/lib/groonga/plugins
254+
238255
CMD ["postgres", "-D", "/etc/postgresql"]

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.5.1.049-orioledb"
14-
postgres17: "17.6.1.028"
15-
postgres15: "15.14.1.028"
13+
postgresorioledb-17: "17.5.1.050-orioledb"
14+
postgres17: "17.6.1.029"
15+
postgres15: "15.14.1.029"
1616

1717
# Non Postgres Extensions
1818
pgbouncer_release: 1.19.0

flake.nix

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
nix/checks.nix
3131
nix/config.nix
3232
nix/devShells.nix
33-
nix/ext
3433
nix/fmt.nix
3534
nix/hooks.nix
3635
nix/nixpkgs.nix

nix/checks.nix

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
psql_15 = self'.packages."psql_15/bin";
1414
psql_17 = self'.packages."psql_17/bin";
1515
psql_orioledb-17 = self'.packages."psql_orioledb-17/bin";
16-
pgroonga = self'.packages."psql_15/exts/pgroonga";
1716
inherit (self.supabase) defaults;
1817
};
1918
in
@@ -68,9 +67,36 @@
6867
'';
6968
};
7069

70+
# Get the major version for filtering
71+
majorVersion =
72+
let
73+
version = builtins.trace "pgpkg.version is: ${pgpkg.version}" pgpkg.version;
74+
isOrioledbMatch = builtins.match "^17_[0-9]+$" version != null;
75+
isSeventeenMatch = builtins.match "^17[.][0-9]+$" version != null;
76+
result =
77+
if isOrioledbMatch then
78+
"orioledb-17"
79+
else if isSeventeenMatch then
80+
"17"
81+
else
82+
"15";
83+
in
84+
builtins.trace "Major version result: ${result}" result;
85+
86+
# Select the appropriate pgroonga package for this PostgreSQL version
87+
pgroonga = self'.packages."psql_${majorVersion}/exts/pgroonga-all";
88+
89+
pgPort =
90+
if (majorVersion == "17") then
91+
"5535"
92+
else if (majorVersion == "15") then
93+
"5536"
94+
else
95+
"5537";
96+
7197
# Use the shared setup but with a test-specific name
7298
start-postgres-server-bin = pkgs-lib.makePostgresDevSetup {
73-
inherit pkgs;
99+
inherit pkgs pgroonga;
74100
name = "start-postgres-server-test";
75101
extraSubstitutions = {
76102
PGSODIUM_GETKEY = "${getkey-script}/bin/pgsodium-getkey";
@@ -116,33 +142,9 @@
116142
in
117143
pkgs.lib.filterAttrs (name: _: isValidFile name) files;
118144

119-
# Get the major version for filtering
120-
majorVersion =
121-
let
122-
version = builtins.trace "pgpkg.version is: ${pgpkg.version}" pgpkg.version;
123-
isOrioledbMatch = builtins.match "^17_[0-9]+$" version != null;
124-
isSeventeenMatch = builtins.match "^17[.][0-9]+$" version != null;
125-
result =
126-
if isOrioledbMatch then
127-
"orioledb-17"
128-
else if isSeventeenMatch then
129-
"17"
130-
else
131-
"15";
132-
in
133-
builtins.trace "Major version result: ${result}" result; # Trace the result # For "15.8"
134-
135145
# Filter SQL test files
136146
filteredSqlTests = filterTestFiles majorVersion ./tests/sql;
137147

138-
pgPort =
139-
if (majorVersion == "17") then
140-
"5535"
141-
else if (majorVersion == "15") then
142-
"5536"
143-
else
144-
"5537";
145-
146148
# Convert filtered tests to a sorted list of basenames (without extension)
147149
testList = pkgs.lib.mapAttrsToList (
148150
name: _: builtins.substring 0 (pkgs.lib.stringLength name - 4) name

nix/ext/default.nix

Lines changed: 0 additions & 11 deletions
This file was deleted.

nix/ext/pgroonga.nix

Lines changed: 0 additions & 95 deletions
This file was deleted.

0 commit comments

Comments
 (0)