-
-
Notifications
You must be signed in to change notification settings - Fork 236
Feat: Postgresql 18 #2051
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
encima
wants to merge
25
commits into
develop
Choose a base branch
from
feat/pg-18
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Feat: Postgresql 18 #2051
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
59e3e29
add 18 to nix config
encima 1a49b8a
add references to 18 in pkgs
encima 3cc699e
add 18 to extension versions
encima 78af79e
fix issue with extensions failing if not supported by any major versions
encima 09801a9
bump pg_cron to 1.6.7, http to 1.6.3 and supautils to 3.1.0, as well …
encima 5fc81ac
updated pg_stat_monitor to 2.3.1 for 18
encima f3acc6a
update pg_graphql to 1.5.12 for 18 support
encima c72b23d
update pgtap to 1.3.4
encima 6008306
update plpgsql_check to 2.8.8 for 18
encima 6c4c222
update rum to 1.3.15
encima b4710ea
update pgroonga to 4.0.5 for 18
encima 1fc8d22
update vector to 0.8.1 for 18
encima 7e8d974
update roonga to 14.0.5 for latest pgroonga
encima ab80d7f
amend patches for groonga due to line number changes
encima 8718d3a
update pg_graphql rust deps for pgrx to support 18
encima d474d51
update rust deps for jsonschema and other pgrx based builds
encima 8fea4dc
update jsonschema to 0.3.4
encima 366b68d
update postgis to 3.6.1
encima 45b045b
fix: extension version issues on arm linux and rebase against develop
encima f14f1b2
add conf exceptions for 18 and bump to 18.3
encima 7233077
add alternative tests for 18 (not versioned but additionally checked …
encima 50fef18
update major PG instructions and ansible file for handling pg18 config
encima 14e8969
update dbmate to use the local flake for checking version to gen for
encima f4663ae
revert version checks now that all have an 18 equivalent
encima 14d8dd1
update Dockerfile to match new format and add slim build support
encima File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,190 @@ | ||
| # syntax=docker/dockerfile:1.6 | ||
| # Alpine-based slim PostgreSQL 18 image with Nix extensions | ||
|
|
||
| #################### | ||
| # Stage 1: Nix builder | ||
| #################### | ||
| FROM alpine:3.21 AS nix-builder | ||
|
|
||
| # Install dependencies for nix installer (coreutils for GNU cp, sudo for installer) | ||
| RUN apk add --no-cache \ | ||
| bash \ | ||
| coreutils \ | ||
| curl \ | ||
| shadow \ | ||
| sudo \ | ||
| xz | ||
|
|
||
| # Create users (Alpine syntax) | ||
| RUN addgroup -S postgres && \ | ||
| adduser -S -h /var/lib/postgresql -s /bin/bash -G postgres postgres && \ | ||
| addgroup -S wal-g && \ | ||
| adduser -S -s /bin/bash -G wal-g wal-g | ||
|
|
||
| # Create nix config | ||
| RUN cat <<EOF > /tmp/extra-nix.conf | ||
| extra-experimental-features = nix-command flakes | ||
| extra-substituters = https://nix-postgres-artifacts.s3.amazonaws.com | ||
| extra-trusted-public-keys = nix-postgres-artifacts:dGZlQOvKcNEjvT7QEAJbcV6b6uk7VF/hWMjhYleiaLI= | ||
| EOF | ||
| RUN curl -L https://releases.nixos.org/nix/nix-2.33.2/install | sh -s -- --daemon --no-channel-add --yes --nix-extra-conf-file /tmp/extra-nix.conf | ||
|
|
||
| ENV PATH="${PATH}:/nix/var/nix/profiles/default/bin" | ||
|
|
||
| WORKDIR /nixpg | ||
| COPY . . | ||
|
|
||
| # Build PostgreSQL with extensions | ||
| RUN nix profile add path:.#psql_18_slim/bin | ||
|
|
||
| RUN nix store gc | ||
|
|
||
| # Build groonga and copy plugins | ||
| RUN nix profile add path:.#supabase-groonga && \ | ||
| mkdir -p /tmp/groonga-plugins && \ | ||
| cp -r /nix/var/nix/profiles/default/lib/groonga/plugins /tmp/groonga-plugins/ | ||
|
|
||
| RUN nix store gc | ||
|
|
||
| #################### | ||
| # Stage 2: Gosu builder | ||
| #################### | ||
| FROM alpine:3.21 AS gosu-builder | ||
|
|
||
| ARG TARGETARCH | ||
| ARG GOSU_VERSION=1.16 | ||
|
|
||
| RUN apk add --no-cache gnupg curl | ||
|
|
||
| # Download and verify gosu | ||
| RUN curl -fsSL "https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-${TARGETARCH}" -o /usr/local/bin/gosu && \ | ||
| curl -fsSL "https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-${TARGETARCH}.asc" -o /usr/local/bin/gosu.asc && \ | ||
| GNUPGHOME="$(mktemp -d)" && \ | ||
| export GNUPGHOME && \ | ||
| gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 && \ | ||
| gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu && \ | ||
| rm -rf "$GNUPGHOME" /usr/local/bin/gosu.asc && \ | ||
| chmod +x /usr/local/bin/gosu | ||
|
|
||
| #################### | ||
| # Stage 3: Final production image | ||
| #################### | ||
| FROM alpine:3.21 AS production | ||
|
|
||
| # Install minimal runtime dependencies | ||
| RUN apk add --no-cache \ | ||
| bash \ | ||
| curl \ | ||
| shadow \ | ||
| su-exec \ | ||
| tzdata \ | ||
| musl-locales \ | ||
| musl-locales-lang \ | ||
| && rm -rf /var/cache/apk/* | ||
|
|
||
| # Create postgres user/group | ||
| RUN addgroup -S postgres && \ | ||
| adduser -S -G postgres -h /var/lib/postgresql -s /bin/bash postgres && \ | ||
| addgroup -S wal-g && \ | ||
| adduser -S -G wal-g -s /bin/bash wal-g && \ | ||
| adduser postgres wal-g | ||
|
|
||
| # Copy Nix store and profiles from builder (profile already created by nix profile install) | ||
| COPY --from=nix-builder /nix /nix | ||
|
|
||
| # Copy groonga plugins | ||
| COPY --from=nix-builder /tmp/groonga-plugins/plugins /usr/lib/groonga/plugins | ||
|
|
||
| # Copy gosu | ||
| COPY --from=gosu-builder /usr/local/bin/gosu /usr/local/bin/gosu | ||
|
|
||
| # Setup PostgreSQL directories | ||
| RUN mkdir -p /usr/lib/postgresql/bin \ | ||
| /usr/lib/postgresql/share/postgresql \ | ||
| /usr/share/postgresql \ | ||
| /var/lib/postgresql/data \ | ||
| /var/run/postgresql \ | ||
| && chown -R postgres:postgres /usr/lib/postgresql \ | ||
| && chown -R postgres:postgres /var/lib/postgresql \ | ||
| && chown -R postgres:postgres /usr/share/postgresql \ | ||
| && chown -R postgres:postgres /var/run/postgresql | ||
|
|
||
| # Create symbolic links for binaries | ||
| RUN for f in /nix/var/nix/profiles/default/bin/*; do \ | ||
| ln -sf "$f" /usr/lib/postgresql/bin/ 2>/dev/null || true; \ | ||
| ln -sf "$f" /usr/bin/ 2>/dev/null || true; \ | ||
| done | ||
|
|
||
| # Create symbolic links for PostgreSQL shares | ||
| RUN ln -sf /nix/var/nix/profiles/default/share/postgresql/* /usr/lib/postgresql/share/postgresql/ 2>/dev/null || true && \ | ||
| ln -sf /nix/var/nix/profiles/default/share/postgresql/* /usr/share/postgresql/ 2>/dev/null || true && \ | ||
| ln -sf /usr/lib/postgresql/share/postgresql/timezonesets /usr/share/postgresql/timezonesets 2>/dev/null || true | ||
|
|
||
| # Set permissions | ||
| RUN chown -R postgres:postgres /usr/lib/postgresql && \ | ||
| chown -R postgres:postgres /usr/share/postgresql | ||
|
|
||
| # Setup configs | ||
| COPY --chown=postgres:postgres ansible/files/postgresql_config/postgresql.conf.j2 /etc/postgresql/postgresql.conf | ||
| COPY --chown=postgres:postgres ansible/files/postgresql_config/pg_hba.conf.j2 /etc/postgresql/pg_hba.conf | ||
| COPY --chown=postgres:postgres ansible/files/postgresql_config/pg_ident.conf.j2 /etc/postgresql/pg_ident.conf | ||
| COPY --chown=postgres:postgres ansible/files/postgresql_config/conf.d /etc/postgresql-custom/conf.d | ||
| COPY --chown=postgres:postgres ansible/files/postgresql_config/postgresql-stdout-log.conf /etc/postgresql/logging.conf | ||
| COPY --chown=postgres:postgres ansible/files/postgresql_config/supautils.conf.j2 /etc/postgresql-custom/supautils.conf | ||
| COPY --chown=postgres:postgres ansible/files/postgresql_extension_custom_scripts /etc/postgresql-custom/extension-custom-scripts | ||
| COPY --chown=postgres:postgres ansible/files/pgsodium_getkey_urandom.sh.j2 /usr/lib/postgresql/bin/pgsodium_getkey.sh | ||
| COPY --chown=postgres:postgres ansible/files/postgresql_config/custom_walg.conf /etc/postgresql-custom/wal-g.conf | ||
| COPY --chown=postgres:postgres ansible/files/postgresql_config/custom_read_replica.conf /etc/postgresql-custom/read-replica.conf | ||
| COPY --chown=postgres:postgres ansible/files/walg_helper_scripts/wal_fetch.sh /home/postgres/wal_fetch.sh | ||
| COPY ansible/files/walg_helper_scripts/wal_change_ownership.sh /root/wal_change_ownership.sh | ||
|
|
||
| # Configure PostgreSQL settings | ||
| 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" /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 && \ | ||
| chown -R postgres:postgres /etc/postgresql-custom | ||
|
|
||
| # Remove timescaledb and plv8 references (not in pg18) | ||
| RUN sed -i 's/ timescaledb,//g;' "/etc/postgresql/postgresql.conf" && \ | ||
| sed -i 's/db_user_namespace = off/#db_user_namespace = off/g;' "/etc/postgresql/postgresql.conf" && \ | ||
| sed -i 's/ timescaledb,//g; s/ plv8,//g' "/etc/postgresql-custom/supautils.conf" | ||
|
|
||
| # Include schema migrations | ||
| COPY migrations/db /docker-entrypoint-initdb.d/ | ||
| COPY ansible/files/pgbouncer_config/pgbouncer_auth_schema.sql /docker-entrypoint-initdb.d/init-scripts/00-schema.sql | ||
| COPY ansible/files/stat_extension.sql /docker-entrypoint-initdb.d/migrations/00-extension.sql | ||
|
|
||
| # Add entrypoint script | ||
| ADD --chmod=0755 \ | ||
| https://github.com/docker-library/postgres/raw/889f9447cd2dfe21cccfbe9bb7945e3b037e02d8/17/bullseye/docker-entrypoint.sh \ | ||
| /usr/local/bin/docker-entrypoint.sh | ||
|
|
||
| # Setup pgsodium key script | ||
| RUN mkdir -p /usr/share/postgresql/extension/ && \ | ||
| ln -s /usr/lib/postgresql/bin/pgsodium_getkey.sh /usr/share/postgresql/extension/pgsodium_getkey && \ | ||
| chmod +x /usr/lib/postgresql/bin/pgsodium_getkey.sh | ||
|
|
||
| # Environment variables | ||
| ENV PATH="/nix/var/nix/profiles/default/bin:/usr/lib/postgresql/bin:${PATH}" | ||
| ENV PGDATA=/var/lib/postgresql/data | ||
encima marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ENV POSTGRES_HOST=/var/run/postgresql | ||
| ENV POSTGRES_USER=supabase_admin | ||
| ENV POSTGRES_DB=postgres | ||
| ENV POSTGRES_INITDB_ARGS="--allow-group-access --locale-provider=icu --encoding=UTF-8 --icu-locale=en_US.UTF-8" | ||
| ENV LANG=en_US.UTF-8 | ||
| ENV LANGUAGE=en_US:en | ||
| ENV LC_ALL=en_US.UTF-8 | ||
| ENV GRN_PLUGINS_DIR=/usr/lib/groonga/plugins | ||
| # Point to minimal glibc locales included in slim Nix package for initdb locale support | ||
| ENV LOCALE_ARCHIVE=/nix/var/nix/profiles/default/lib/locale/locale-archive | ||
|
|
||
| ENTRYPOINT ["docker-entrypoint.sh"] | ||
| HEALTHCHECK --interval=2s --timeout=2s --retries=10 CMD pg_isready -U postgres -h localhost | ||
| STOPSIGNAL SIGINT | ||
| EXPOSE 5432 | ||
|
|
||
| CMD ["postgres", "-D", "/etc/postgresql"] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.