From dff4603038c08f513e0ae7b13549fa0ba1869625 Mon Sep 17 00:00:00 2001 From: phmai Date: Mon, 7 Apr 2025 12:36:25 +0200 Subject: [PATCH 01/13] CASL-949 upgrade to postgres 17.4 Signed-off-by: phmai --- deployment/docker/postgres/naksha-pg-0-base/Dockerfile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/deployment/docker/postgres/naksha-pg-0-base/Dockerfile b/deployment/docker/postgres/naksha-pg-0-base/Dockerfile index b92e444993..f14f85c897 100644 --- a/deployment/docker/postgres/naksha-pg-0-base/Dockerfile +++ b/deployment/docker/postgres/naksha-pg-0-base/Dockerfile @@ -6,12 +6,12 @@ FROM public.ecr.aws/amazonlinux/amazonlinux:latest RUN dnf update -y RUN dnf install -y bison-devel readline-devel zlib-devel openssl-devel wget vim RUN dnf install -y mlocate icu libicu-devel e2fsprogs e2fsprogs-devel lz4 lz4-devel uuid uuid-devel sudo -RUN dnf install -y --allowerasing curl curl-devel +RUN dnf install -y --allowerasing curl curl-devel perl docbook-xsl libxslt RUN dnf -y groupinstall "Development Tools" RUN cd /tmp/ \ - && wget https://ftp.postgresql.org/pub/source/v16.2/postgresql-16.2.tar.gz \ - && tar xzf postgresql-16.2.tar.gz \ - && cd postgresql-16.2 \ + && wget https://ftp.postgresql.org/pub/source/v17.4/postgresql-17.4.tar.gz \ + && tar xzf postgresql-17.4.tar.gz \ + && cd postgresql-17.4 \ && ./configure --prefix=/usr/local --with-blocksize=32 --with-wal-blocksize=32 --with-lz4 --with-zstd --with-openssl --with-uuid=ossp \ && make world WITH_PGBLOCKSIZE=32K \ && groupadd postgres -g 5430 \ @@ -23,4 +23,4 @@ RUN cd /tmp/ \ EXPOSE 5432 -CMD /usr/bin/run_postgres.sh +CMD ["/usr/bin/run_postgres.sh"] From d95155d50412984ae5cffb6105fbb7c94f8ea6b2 Mon Sep 17 00:00:00 2001 From: phmai Date: Mon, 7 Apr 2025 14:36:45 +0200 Subject: [PATCH 02/13] CASL-949 resolve jsonarg warning and add incomplete plrust dockerfile Signed-off-by: phmai --- deployment/docker/README.md | 36 ++++++++++++------- .../postgres/naksha-pg-1-postgis/Dockerfile | 2 +- .../postgres/naksha-pg-2-plv8/Dockerfile | 2 +- .../postgres/naksha-pg-3-misc/Dockerfile | 2 +- .../postgres/naksha-pg-4-pljava/Dockerfile | 2 +- .../postgres/naksha-pg-5-plrust/Dockerfile | 14 ++++++++ .../postgres/naksha-pg-release/Dockerfile | 4 +-- 7 files changed, 43 insertions(+), 19 deletions(-) create mode 100644 deployment/docker/postgres/naksha-pg-5-plrust/Dockerfile diff --git a/deployment/docker/README.md b/deployment/docker/README.md index 9bf9980fed..1926980f86 100644 --- a/deployment/docker/README.md +++ b/deployment/docker/README.md @@ -27,7 +27,8 @@ The PostgresQL docker will be build in multiple steps: - Step 2: Build the [PLV8 extension](./naksha-pg-2-plv8) - Step 3: Build other [miscellaneous extensions](./naksha-pg-3-misc) like GZIP - Step 4: Build [PL/Java extension](./naksha-pg-4-pljava), which is experimental for now -- Step 5: Build the [release](./naksha-pg-release) that contains configuration and start script, we do it as a standalone step, because this allows easily to change the configuration of the PostgresQL database without the need to compile anything again. +- Step 5: Build [PL/Rust extension](./naksha-pg-5-plrust) +- Step 6: Build the [release](./naksha-pg-release) that contains configuration and start script, we do it as a standalone step, because this allows easily to change the configuration of the PostgresQL database without the need to compile anything again. ### Build The Naksha PostgresQL image is build in steps, follow these instructions: @@ -35,12 +36,13 @@ The Naksha PostgresQL image is build in steps, follow these instructions: ```bash # Define postgres version, and revision to be build # v{pg-major}.{pg-minor}[.{pg-revision}]-r{revision} -export BASE_VER="v16.2-r4" -export POSTGIS_VER="v16.2-r4" -export PLV8_VER="v16.2-r4" -export MISC_VER="v16.2-r4" -export PLJAVA_VER="v16.2-r4" -export RELEASE_VER="v16.2-r4" +export BASE_VER="v17.4-r0" +export POSTGIS_VER="v17.4-r0" +export PLV8_VER="v17.4-r0" +export MISC_VER="v17.4-r0" +export PLJAVA_VER="v17.4-r0" +export PLRUST_VER="v17.4-r0" +export RELEASE_VER="v17.4-r0" ``` Ones done, start compiling @@ -48,12 +50,12 @@ Ones done, start compiling ```bash cd deployment/docker/postgres -# Build base image and push +# Build base image cd naksha-pg-0-base docker build --platform=linux/arm64,linux/amd64 -t "$DR_NAKSHA_POSTGRES:base-${BASE_VER}" . cd .. -# Build postgis image and push +# Build postgis image cd naksha-pg-1-postgis docker build --platform=linux/arm64,linux/amd64 \ --build-arg="DR_NAKSHA_POSTGRES=$DR_NAKSHA_POSTGRES" \ @@ -61,7 +63,7 @@ docker build --platform=linux/arm64,linux/amd64 \ -t "${DR_NAKSHA_POSTGRES}:postgis-${POSTGIS_VER}" . cd .. -# Build plv8 image and push +# Build plv8 image cd naksha-pg-2-plv8 docker build --platform=linux/arm64,linux/amd64 \ --build-arg="DR_NAKSHA_POSTGRES=$DR_NAKSHA_POSTGRES" \ @@ -69,7 +71,7 @@ docker build --platform=linux/arm64,linux/amd64 \ -t "${DR_NAKSHA_POSTGRES}:plv8-${PLV8_VER}" . cd .. -# Build miscellaneous image and push +# Build miscellaneous image cd naksha-pg-3-misc docker build --platform=linux/arm64,linux/amd64 \ --build-arg="DR_NAKSHA_POSTGRES=$DR_NAKSHA_POSTGRES" \ @@ -77,7 +79,7 @@ docker build --platform=linux/arm64,linux/amd64 \ -t "${DR_NAKSHA_POSTGRES}:misc-${MISC_VER}" . cd .. -# Build pljava image and push +# Build pljava image cd naksha-pg-4-pljava docker build --platform=linux/arm64,linux/amd64 \ --build-arg="DR_NAKSHA_POSTGRES=$DR_NAKSHA_POSTGRES" \ @@ -85,13 +87,21 @@ docker build --platform=linux/arm64,linux/amd64 \ -t "${DR_NAKSHA_POSTGRES}:pljava-${PLJAVA_VER}" . cd .. +# Build plrust image +cd naksha-pg-5-plrust +docker build --platform=linux/arm64,linux/amd64 \ + --build-arg="DR_NAKSHA_POSTGRES=$DR_NAKSHA_POSTGRES" \ + --build-arg="VERSION=${PLJAVA_VER}" \ + -t "${DR_NAKSHA_POSTGRES}:plrust-${PLRUST_VER}" . +cd .. + # Build the final postgres with run-scripts and default configurations # Note, this can be done multiple times without any need to re-build the previous images # Therefore we introduce the BASE var cd naksha-pg-release docker build --platform=linux/arm64,linux/amd64 \ --build-arg="DR_NAKSHA_POSTGRES=$DR_NAKSHA_POSTGRES" \ - --build-arg="VERSION=${PLJAVA_VER}" \ + --build-arg="VERSION=${PLRUST_VER}" \ -t "${DR_NAKSHA_POSTGRES}:${RELEASE_VER}" \ -t "${DR_NAKSHA_POSTGRES}:latest" . ``` diff --git a/deployment/docker/postgres/naksha-pg-1-postgis/Dockerfile b/deployment/docker/postgres/naksha-pg-1-postgis/Dockerfile index 907ed8a365..6602952c23 100644 --- a/deployment/docker/postgres/naksha-pg-1-postgis/Dockerfile +++ b/deployment/docker/postgres/naksha-pg-1-postgis/Dockerfile @@ -93,4 +93,4 @@ RUN dnf install -y libxml2 libxml2-devel cmake \ EXPOSE 5432 -CMD /usr/bin/run_postgres.sh +CMD ["/usr/bin/run_postgres.sh"] \ No newline at end of file diff --git a/deployment/docker/postgres/naksha-pg-2-plv8/Dockerfile b/deployment/docker/postgres/naksha-pg-2-plv8/Dockerfile index c973c3bb92..afdf941f0e 100644 --- a/deployment/docker/postgres/naksha-pg-2-plv8/Dockerfile +++ b/deployment/docker/postgres/naksha-pg-2-plv8/Dockerfile @@ -17,4 +17,4 @@ RUN cd /tmp/ \ EXPOSE 5432 -CMD /usr/bin/run_postgres.sh +CMD ["/usr/bin/run_postgres.sh"] \ No newline at end of file diff --git a/deployment/docker/postgres/naksha-pg-3-misc/Dockerfile b/deployment/docker/postgres/naksha-pg-3-misc/Dockerfile index 451db00a6b..9c30637143 100644 --- a/deployment/docker/postgres/naksha-pg-3-misc/Dockerfile +++ b/deployment/docker/postgres/naksha-pg-3-misc/Dockerfile @@ -43,4 +43,4 @@ RUN cd /tmp/ \ EXPOSE 5432 -CMD /usr/bin/run_postgres.sh +CMD ["/usr/bin/run_postgres.sh"] \ No newline at end of file diff --git a/deployment/docker/postgres/naksha-pg-4-pljava/Dockerfile b/deployment/docker/postgres/naksha-pg-4-pljava/Dockerfile index a2b503cd38..b2bf4aa767 100644 --- a/deployment/docker/postgres/naksha-pg-4-pljava/Dockerfile +++ b/deployment/docker/postgres/naksha-pg-4-pljava/Dockerfile @@ -22,4 +22,4 @@ RUN dnf install -y java-21-amazon-corretto maven \ EXPOSE 5432 -CMD /usr/bin/run_postgres.sh +CMD ["/usr/bin/run_postgres.sh"] \ No newline at end of file diff --git a/deployment/docker/postgres/naksha-pg-5-plrust/Dockerfile b/deployment/docker/postgres/naksha-pg-5-plrust/Dockerfile new file mode 100644 index 0000000000..ee9881f124 --- /dev/null +++ b/deployment/docker/postgres/naksha-pg-5-plrust/Dockerfile @@ -0,0 +1,14 @@ +ARG DR_NAKSHA_POSTGRES=hcr.data.here.com/naksha/postgres +ARG VERSION +FROM ${DR_NAKSHA_POSTGRES}:pljava-${VERSION} + +# https://github.com/tcdi/plrust +RUN cd /tmp/ \ + && curl --tlsv1.3 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain stable -y \ + && \ +# Cleanup + && rm -rf /tmp/* + +EXPOSE 5432 + +CMD ["/usr/bin/run_postgres.sh"] \ No newline at end of file diff --git a/deployment/docker/postgres/naksha-pg-release/Dockerfile b/deployment/docker/postgres/naksha-pg-release/Dockerfile index e05d906964..04ceef0580 100644 --- a/deployment/docker/postgres/naksha-pg-release/Dockerfile +++ b/deployment/docker/postgres/naksha-pg-release/Dockerfile @@ -1,6 +1,6 @@ ARG DR_NAKSHA_POSTGRES=hcr.data.here.com/naksha/postgres ARG VERSION -FROM ${DR_NAKSHA_POSTGRES}:pljava-${VERSION} +FROM ${DR_NAKSHA_POSTGRES}:plrust-${VERSION} ADD files / @@ -12,4 +12,4 @@ RUN chown postgres:postgres /usr/bin/run_postgres.sh \ EXPOSE 5432 -CMD /usr/bin/run_postgres.sh +CMD ["/usr/bin/run_postgres.sh"] \ No newline at end of file From f26fc5dfd16a2911b0746989d3d925d58ec992d5 Mon Sep 17 00:00:00 2001 From: phmai Date: Mon, 7 Apr 2025 15:39:24 +0200 Subject: [PATCH 03/13] CASL-949 bump extension versions to support postgres 17 Signed-off-by: phmai --- deployment/docker/postgres/naksha-pg-2-plv8/Dockerfile | 2 +- deployment/docker/postgres/naksha-pg-3-misc/Dockerfile | 2 +- deployment/docker/postgres/naksha-pg-4-pljava/Dockerfile | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/deployment/docker/postgres/naksha-pg-2-plv8/Dockerfile b/deployment/docker/postgres/naksha-pg-2-plv8/Dockerfile index afdf941f0e..feadb20f03 100644 --- a/deployment/docker/postgres/naksha-pg-2-plv8/Dockerfile +++ b/deployment/docker/postgres/naksha-pg-2-plv8/Dockerfile @@ -7,7 +7,7 @@ FROM ${DR_NAKSHA_POSTGRES}:postgis-${VERSION} RUN cd /tmp/ \ && git clone https://github.com/plv8/plv8.git \ && cd plv8 \ - && git checkout v3.2.2 \ + && git checkout v3.2.3 \ && make \ && make install \ # SELECT * FROM pg_available_extensions WHERE name = 'plv8'; diff --git a/deployment/docker/postgres/naksha-pg-3-misc/Dockerfile b/deployment/docker/postgres/naksha-pg-3-misc/Dockerfile index 9c30637143..faf80dd51b 100644 --- a/deployment/docker/postgres/naksha-pg-3-misc/Dockerfile +++ b/deployment/docker/postgres/naksha-pg-3-misc/Dockerfile @@ -24,7 +24,7 @@ RUN cd /tmp/ \ && cd /tmp/ \ && git clone https://github.com/citusdata/pg_cron.git \ && cd pg_cron \ - && git checkout v1.6.2 \ + && git checkout v1.6.4 \ && make \ && make install \ # SELECT * FROM pg_available_extensions WHERE name = 'pg_cron'; diff --git a/deployment/docker/postgres/naksha-pg-4-pljava/Dockerfile b/deployment/docker/postgres/naksha-pg-4-pljava/Dockerfile index b2bf4aa767..7a3cf1d532 100644 --- a/deployment/docker/postgres/naksha-pg-4-pljava/Dockerfile +++ b/deployment/docker/postgres/naksha-pg-4-pljava/Dockerfile @@ -12,9 +12,9 @@ RUN dnf install -y java-21-amazon-corretto maven \ && cd /tmp/ \ && git clone https://github.com/tada/pljava.git \ && cd pljava \ - && git checkout V1_6_6 \ + && git checkout V1_6_9 \ && mvn clean install \ - && java -jar pljava-packaging/target/pljava-pg16.jar \ + && java -jar pljava-packaging/target/pljava-pg17.jar \ # SELECT * FROM pg_available_extensions WHERE name = 'pljava'; # # Cleanup From 9b816fa8c04b67df5601b7475fd367523f04a1f1 Mon Sep 17 00:00:00 2001 From: phmai Date: Mon, 7 Apr 2025 16:11:52 +0200 Subject: [PATCH 04/13] CASL-949 delay PL Rust addition until support for Postgresql 17 included Signed-off-by: phmai --- deployment/docker/README.md | 16 +++++---- .../postgres/naksha-pg-5-plrust/Dockerfile | 33 ++++++++++++++++--- .../postgres/naksha-pg-release/Dockerfile | 3 +- 3 files changed, 39 insertions(+), 13 deletions(-) diff --git a/deployment/docker/README.md b/deployment/docker/README.md index 1926980f86..3fc390a13a 100644 --- a/deployment/docker/README.md +++ b/deployment/docker/README.md @@ -88,12 +88,12 @@ docker build --platform=linux/arm64,linux/amd64 \ cd .. # Build plrust image -cd naksha-pg-5-plrust -docker build --platform=linux/arm64,linux/amd64 \ - --build-arg="DR_NAKSHA_POSTGRES=$DR_NAKSHA_POSTGRES" \ - --build-arg="VERSION=${PLJAVA_VER}" \ - -t "${DR_NAKSHA_POSTGRES}:plrust-${PLRUST_VER}" . -cd .. +#cd naksha-pg-5-plrust +#docker build --platform=linux/arm64,linux/amd64 \ +# --build-arg="DR_NAKSHA_POSTGRES=$DR_NAKSHA_POSTGRES" \ +# --build-arg="VERSION=${PLJAVA_VER}" \ +# -t "${DR_NAKSHA_POSTGRES}:plrust-${PLRUST_VER}" . +#cd .. # Build the final postgres with run-scripts and default configurations # Note, this can be done multiple times without any need to re-build the previous images @@ -101,9 +101,11 @@ cd .. cd naksha-pg-release docker build --platform=linux/arm64,linux/amd64 \ --build-arg="DR_NAKSHA_POSTGRES=$DR_NAKSHA_POSTGRES" \ - --build-arg="VERSION=${PLRUST_VER}" \ + --build-arg="VERSION=${PLJAVA_VER}" \ -t "${DR_NAKSHA_POSTGRES}:${RELEASE_VER}" \ -t "${DR_NAKSHA_POSTGRES}:latest" . +cd .. +# --build-arg="VERSION=${PLRUST_VER}" \ for later when we include PL Rust ``` **Notes**: diff --git a/deployment/docker/postgres/naksha-pg-5-plrust/Dockerfile b/deployment/docker/postgres/naksha-pg-5-plrust/Dockerfile index ee9881f124..2f92e39e1f 100644 --- a/deployment/docker/postgres/naksha-pg-5-plrust/Dockerfile +++ b/deployment/docker/postgres/naksha-pg-5-plrust/Dockerfile @@ -1,13 +1,36 @@ ARG DR_NAKSHA_POSTGRES=hcr.data.here.com/naksha/postgres ARG VERSION +ARG TARGETPLATFORM FROM ${DR_NAKSHA_POSTGRES}:pljava-${VERSION} + +# TOO BADDDD!!!!!!!!!!!!!! PL RUST DOES NOT SUPPORT POSTGRESQL 17 YET!!!!!!!!!!!!!!!!! + + + + # https://github.com/tcdi/plrust -RUN cd /tmp/ \ - && curl --tlsv1.3 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain stable -y \ - && \ -# Cleanup - && rm -rf /tmp/* +# https://plrust.io/install-plrust.html#trusted-installation-plus-cross-compilation +RUN curl --tlsv1.3 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain stable -y \ + && rustup component add llvm-tools-preview rustc-dev \ + && if [ "${TARGETPLATFORM}" = "linux/arm64" ]; then \ + rustup target install aarch64-unknown-linux-gnu; \ + elif [ "${TARGETPLATFORM}" = "linux/amd64" ]; then \ + rustup target install x86_64-unknown-linux-gnu; \ + fi \ + && cd ~/plrust/plrustc \ + && ./build.sh \ + && mv ~/plrust/build/bin/plrustc ~/.cargo/bin/ \ +# install postgrestd + && cd ~/plrust/plrust \ + && PG_VER=17 \ + && if [ "${TARGETPLATFORM}" = "linux/arm64" ]; then \ + STD_TARGETS="aarch64-postgres-linux-gnu "; \ + elif [ "${TARGETPLATFORM}" = "linux/amd64" ]; then \ + STD_TARGETS="x86_64-postgres-linux-gnu "; \ + fi \ + && ./build \ + && cargo pgrx install --release --features trusted -c /usr/bin/pg_config EXPOSE 5432 diff --git a/deployment/docker/postgres/naksha-pg-release/Dockerfile b/deployment/docker/postgres/naksha-pg-release/Dockerfile index 04ceef0580..04053466cb 100644 --- a/deployment/docker/postgres/naksha-pg-release/Dockerfile +++ b/deployment/docker/postgres/naksha-pg-release/Dockerfile @@ -1,6 +1,7 @@ ARG DR_NAKSHA_POSTGRES=hcr.data.here.com/naksha/postgres ARG VERSION -FROM ${DR_NAKSHA_POSTGRES}:plrust-${VERSION} +FROM ${DR_NAKSHA_POSTGRES}:pljava-${VERSION} +#FROM ${DR_NAKSHA_POSTGRES}:plrust-${VERSION} ADD files / From 8a5985e070c9f21b406e086798e8c2e051be2216 Mon Sep 17 00:00:00 2001 From: phmai Date: Mon, 7 Apr 2025 16:17:37 +0200 Subject: [PATCH 05/13] CASL-949 adjust instruction Signed-off-by: phmai --- deployment/docker/README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/deployment/docker/README.md b/deployment/docker/README.md index 3fc390a13a..89c3bed534 100644 --- a/deployment/docker/README.md +++ b/deployment/docker/README.md @@ -36,16 +36,16 @@ The Naksha PostgresQL image is build in steps, follow these instructions: ```bash # Define postgres version, and revision to be build # v{pg-major}.{pg-minor}[.{pg-revision}]-r{revision} -export BASE_VER="v17.4-r0" -export POSTGIS_VER="v17.4-r0" -export PLV8_VER="v17.4-r0" -export MISC_VER="v17.4-r0" -export PLJAVA_VER="v17.4-r0" -export PLRUST_VER="v17.4-r0" -export RELEASE_VER="v17.4-r0" +export BASE_VER="v17.4-r1" +export POSTGIS_VER="v17.4-r1" +export PLV8_VER="v17.4-r1" +export MISC_VER="v17.4-r1" +export PLJAVA_VER="v17.4-r1" +export PLRUST_VER="v17.4-r1" +export RELEASE_VER="v17.4-r1" ``` -Ones done, start compiling +Once done, start compiling ```bash cd deployment/docker/postgres From 780b39e04b3084bb7d818e225f88b235a64a59e1 Mon Sep 17 00:00:00 2001 From: phmai Date: Tue, 8 Apr 2025 13:39:19 +0200 Subject: [PATCH 06/13] CASL-949 keep a separate backup for postgres 16 with PL Rust Signed-off-by: phmai --- .../naksha-pg-0-base/Dockerfile | 26 ++ .../naksha-pg-1-postgis/Dockerfile | 96 +++++ .../naksha-pg-2-plv8/Dockerfile | 20 + .../naksha-pg-3-misc/Dockerfile | 46 +++ .../naksha-pg-4-pljava/Dockerfile | 25 ++ .../naksha-pg-5-plrust/Dockerfile | 51 +++ .../naksha-pg-release/Dockerfile | 15 + .../naksha-pg-release/files/LICENSE | 202 ++++++++++ .../home/postgres/.config/rclone/rclone.conf | 5 + .../files/home/postgres/pg_hba.conf | 96 +++++ .../files/home/postgres/postgresql.conf | 362 ++++++++++++++++++ .../files/home/postgres/r6idn.metal.conf | 21 + .../files/usr/bin/run_postgres.sh | 92 +++++ 13 files changed, 1057 insertions(+) create mode 100644 deployment/docker/postgres16WithPLRust/naksha-pg-0-base/Dockerfile create mode 100644 deployment/docker/postgres16WithPLRust/naksha-pg-1-postgis/Dockerfile create mode 100644 deployment/docker/postgres16WithPLRust/naksha-pg-2-plv8/Dockerfile create mode 100644 deployment/docker/postgres16WithPLRust/naksha-pg-3-misc/Dockerfile create mode 100644 deployment/docker/postgres16WithPLRust/naksha-pg-4-pljava/Dockerfile create mode 100644 deployment/docker/postgres16WithPLRust/naksha-pg-5-plrust/Dockerfile create mode 100644 deployment/docker/postgres16WithPLRust/naksha-pg-release/Dockerfile create mode 100644 deployment/docker/postgres16WithPLRust/naksha-pg-release/files/LICENSE create mode 100644 deployment/docker/postgres16WithPLRust/naksha-pg-release/files/home/postgres/.config/rclone/rclone.conf create mode 100644 deployment/docker/postgres16WithPLRust/naksha-pg-release/files/home/postgres/pg_hba.conf create mode 100644 deployment/docker/postgres16WithPLRust/naksha-pg-release/files/home/postgres/postgresql.conf create mode 100644 deployment/docker/postgres16WithPLRust/naksha-pg-release/files/home/postgres/r6idn.metal.conf create mode 100755 deployment/docker/postgres16WithPLRust/naksha-pg-release/files/usr/bin/run_postgres.sh diff --git a/deployment/docker/postgres16WithPLRust/naksha-pg-0-base/Dockerfile b/deployment/docker/postgres16WithPLRust/naksha-pg-0-base/Dockerfile new file mode 100644 index 0000000000..3ecf06293e --- /dev/null +++ b/deployment/docker/postgres16WithPLRust/naksha-pg-0-base/Dockerfile @@ -0,0 +1,26 @@ +FROM public.ecr.aws/amazonlinux/amazonlinux:latest + +# Execute all commands at ones, so we only get one layer + +# Install PostgresQL (https://www.postgresql.org/ftp/source/) +RUN dnf update -y +RUN dnf install -y bison-devel readline-devel zlib-devel openssl-devel wget vim +RUN dnf install -y mlocate icu libicu-devel e2fsprogs e2fsprogs-devel lz4 lz4-devel uuid uuid-devel sudo +RUN dnf install -y --allowerasing curl curl-devel +RUN dnf -y groupinstall "Development Tools" +RUN cd /tmp/ \ + && wget https://ftp.postgresql.org/pub/source/v16.8/postgresql-16.8.tar.gz \ + && tar xzf postgresql-16.8.tar.gz \ + && cd postgresql-16.8 \ + && ./configure --prefix=/usr/local --with-blocksize=32 --with-wal-blocksize=32 --with-lz4 --with-zstd --with-openssl --with-uuid=ossp \ + && make world WITH_PGBLOCKSIZE=32K \ + && groupadd postgres -g 5430 \ + && useradd postgres -u 5432 -g 5430 \ + && make install-world \ + && updatedb \ +# Cleanup + && rm -rf /tmp/* + +EXPOSE 5432 + +CMD ["/usr/bin/run_postgres.sh"] diff --git a/deployment/docker/postgres16WithPLRust/naksha-pg-1-postgis/Dockerfile b/deployment/docker/postgres16WithPLRust/naksha-pg-1-postgis/Dockerfile new file mode 100644 index 0000000000..6602952c23 --- /dev/null +++ b/deployment/docker/postgres16WithPLRust/naksha-pg-1-postgis/Dockerfile @@ -0,0 +1,96 @@ +ARG DR_NAKSHA_POSTGRES=hcr.data.here.com/naksha/postgres +ARG VERSION +FROM ${DR_NAKSHA_POSTGRES}:base-${VERSION} + +# +# Install Geos (https://libgeos.org/usage/download/) +RUN dnf install -y libxml2 libxml2-devel cmake \ + && cd /tmp/ \ + && wget https://download.osgeo.org/geos/geos-3.12.1.tar.bz2 \ + && tar xjf geos-3.12.1.tar.bz2 \ + && cd geos-3.12.1 \ + && mkdir _build \ + && cd _build \ + && cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local .. \ + && make \ + && make install \ + && echo "/usr/local/lib64" > /etc/ld.so.conf.d/usr_local_lib64.conf \ + && rm /etc/ld.so.cache && ldconfig \ +# Test if library is available: ldconfig -v -N | grep geos +# +# Proj4 (https://proj.org/en/9.4/development/index.html) +# https://github.com/OSGeo/PROJ + && dnf install -y sqlite sqlite-devel libtiff libtiff-devel \ + && cd /tmp/ \ + && git clone https://github.com/OSGeo/PROJ.git \ + && cd PROJ \ + && git checkout 9.4 \ + && mkdir build \ + && cd build \ + && cmake .. \ + && cmake --build . \ + && cmake --build . --target install \ + && rm /etc/ld.so.cache && ldconfig \ +# +# Install GDal (https://gdal.org/index.html) +# https://github.com/OSGeo/gdal + && dnf install -y python3-devel python3-setuptools \ + && cd /tmp/ \ + && git clone https://github.com/OSGeo/gdal.git \ + && cd gdal \ + && git checkout v3.8.4 \ + && mkdir build \ + && cd build \ + && cmake -DCMAKE_BUILD_TYPE=Release .. \ + && cmake --build . \ + && cmake --build . --target install \ +# Test if library is available: ldconfig -v -N | grep jdal +# JSON-C +# This library is needed for some POSTGIS functions +# See: https://postgis.net/docs/postgis_installation.html#installation_configuration +# https://github.com/json-c/json-c + && cd /tmp/ \ + && git clone https://github.com/json-c/json-c.git \ + && cd json-c \ + && git checkout json-c-0.17 \ + && mkdir json-c-build \ + && cd json-c-build \ + && cmake .. -DCMAKE_BUILD_TYPE=Release \ + && make \ + && make install \ + && rm /etc/ld.so.cache && ldconfig \ +# Test if library is available: ldconfig -v -N | grep json-c +# PCRE +# See: https://postgis.net/docs/postgis_installation.html#installation_configuration +# https://github.com/PCRE2Project/pcre2 \ + && cd /tmp/ \ + && git clone https://github.com/PCRE2Project/pcre2.git \ + && cd pcre2 \ + && git checkout pcre2-10.43 \ + && mkdir pcre2-build \ + && cd pcre2-build \ + && cmake .. -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=OFF \ + && make \ + && make install \ + && rm /etc/ld.so.cache && ldconfig \ +# Test if library is available: ldconfig -v -N | grep pcre2 +# PostGis extension +# https://postgis.net/docs/postgis_installation.html +# https://git.osgeo.org/gitea/postgis/postgis + && dnf install -y protobuf protobuf-devel protobuf-c-devel libxslt libxslt-devel autoconf autoconf-archive perl-Time-HiRes libpq libpq-devel \ + && cd /tmp/ \ + && git clone https://git.osgeo.org/gitea/postgis/postgis.git \ + && cd postgis \ + && git checkout 3.4.2 \ + && ./autogen.sh \ + && ./configure \ + && make \ + && export PGUSER=postgres \ + && make install \ +# SELECT * FROM pg_available_extensions WHERE name = 'postgis'; +# Cleanup + && rm -rf /tmp/* + +EXPOSE 5432 + +CMD ["/usr/bin/run_postgres.sh"] \ No newline at end of file diff --git a/deployment/docker/postgres16WithPLRust/naksha-pg-2-plv8/Dockerfile b/deployment/docker/postgres16WithPLRust/naksha-pg-2-plv8/Dockerfile new file mode 100644 index 0000000000..feadb20f03 --- /dev/null +++ b/deployment/docker/postgres16WithPLRust/naksha-pg-2-plv8/Dockerfile @@ -0,0 +1,20 @@ +ARG DR_NAKSHA_POSTGRES=hcr.data.here.com/naksha/postgres +ARG VERSION +FROM ${DR_NAKSHA_POSTGRES}:postgis-${VERSION} + +# PLV8 extension (https://github.com/plv8/plv8.git) +# Note: Very slow, requires one hour! +RUN cd /tmp/ \ + && git clone https://github.com/plv8/plv8.git \ + && cd plv8 \ + && git checkout v3.2.3 \ + && make \ + && make install \ +# SELECT * FROM pg_available_extensions WHERE name = 'plv8'; +# +# Cleanup + && rm -rf /tmp/* + +EXPOSE 5432 + +CMD ["/usr/bin/run_postgres.sh"] \ No newline at end of file diff --git a/deployment/docker/postgres16WithPLRust/naksha-pg-3-misc/Dockerfile b/deployment/docker/postgres16WithPLRust/naksha-pg-3-misc/Dockerfile new file mode 100644 index 0000000000..faf80dd51b --- /dev/null +++ b/deployment/docker/postgres16WithPLRust/naksha-pg-3-misc/Dockerfile @@ -0,0 +1,46 @@ +ARG DR_NAKSHA_POSTGRES=hcr.data.here.com/naksha/postgres +ARG VERSION +FROM ${DR_NAKSHA_POSTGRES}:plv8-${VERSION} + +# GZIP extension (https://github.com/pramsey/pgsql-gzip/) +RUN cd /tmp/ \ + && git clone https://github.com/pramsey/pgsql-gzip.git \ + && cd pgsql-gzip \ + && git checkout v1.0.0 \ + && make \ + && make install \ +# SELECT * FROM pg_available_extensions WHERE name = 'gzip'; +# +# pg_hint_plan extension (https://github.com/ossc-db/pg_hint_plan) + && cd /tmp/ \ + && git clone https://github.com/ossc-db/pg_hint_plan.git \ + && cd pg_hint_plan \ + && git checkout REL16_1_6_0 \ + && make \ + && make install \ +# SELECT * FROM pg_available_extensions WHERE name = 'pg_hint_plan'; +# +# pg_cron extension (https://github.com/citusdata/pg_cron) + && cd /tmp/ \ + && git clone https://github.com/citusdata/pg_cron.git \ + && cd pg_cron \ + && git checkout v1.6.4 \ + && make \ + && make install \ +# SELECT * FROM pg_available_extensions WHERE name = 'pg_cron'; +# +# pg_partman (https://github.com/pgpartman/pg_partman) + && cd /tmp/ \ + && git clone https://github.com/pgpartman/pg_partman.git \ + && cd pg_partman \ + && git checkout v5.0.1 \ + && make \ + && make install \ +# SELECT * FROM pg_available_extensions WHERE name = 'pg_partman'; +# +# Cleanup + && rm -rf /tmp/* + +EXPOSE 5432 + +CMD ["/usr/bin/run_postgres.sh"] \ No newline at end of file diff --git a/deployment/docker/postgres16WithPLRust/naksha-pg-4-pljava/Dockerfile b/deployment/docker/postgres16WithPLRust/naksha-pg-4-pljava/Dockerfile new file mode 100644 index 0000000000..7a3cf1d532 --- /dev/null +++ b/deployment/docker/postgres16WithPLRust/naksha-pg-4-pljava/Dockerfile @@ -0,0 +1,25 @@ +ARG DR_NAKSHA_POSTGRES=hcr.data.here.com/naksha/postgres +ARG VERSION +FROM ${DR_NAKSHA_POSTGRES}:misc-${VERSION} + +# PL/Java (https://tada.github.io/pljava/) +# https://github.com/tada/pljava +# https://tada.github.io/pljava/install/install.html +# https://tada.github.io/pljava/use/policy.html +# https://www.percona.com/blog/postgresql-pl-java-how-to-part-1/ +# https://www.slideshare.net/petereisentraut/postgresql-and-pljava +RUN dnf install -y java-21-amazon-corretto maven \ + && cd /tmp/ \ + && git clone https://github.com/tada/pljava.git \ + && cd pljava \ + && git checkout V1_6_9 \ + && mvn clean install \ + && java -jar pljava-packaging/target/pljava-pg17.jar \ +# SELECT * FROM pg_available_extensions WHERE name = 'pljava'; +# +# Cleanup + && rm -rf /tmp/* + +EXPOSE 5432 + +CMD ["/usr/bin/run_postgres.sh"] \ No newline at end of file diff --git a/deployment/docker/postgres16WithPLRust/naksha-pg-5-plrust/Dockerfile b/deployment/docker/postgres16WithPLRust/naksha-pg-5-plrust/Dockerfile new file mode 100644 index 0000000000..4fd0499704 --- /dev/null +++ b/deployment/docker/postgres16WithPLRust/naksha-pg-5-plrust/Dockerfile @@ -0,0 +1,51 @@ +ARG DR_NAKSHA_POSTGRES=hcr.data.here.com/naksha/postgres +ARG VERSION +ARG TARGETPLATFORM +FROM ${DR_NAKSHA_POSTGRES}:pljava-${VERSION} + +# https://github.com/tcdi/plrust +# https://plrust.io/install-plrust.html#trusted-installation-plus-cross-compilation +RUN chown postgres -R /usr/share/postgresql/16/extension/ \ + && chown postgres -R /usr/lib/postgresql/15/lib/ \ +USER postgres +RUN cd /tmp/ \ + && curl --tlsv1.3 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain stable -y \ + && git clone https://github.com/tcdi/plrust.git \ + && rustup default 1.86.0 \ +# install pgrx + && cargo install cargo-pgrx --locked \ + && cargo pgrx init --pg16 /usr/local/bin/pg_config \ + && rustup component add llvm-tools-preview rustc-dev \ + && if [ "${TARGETPLATFORM}" = "linux/arm64" ]; then \ + rustup target install aarch64-unknown-linux-gnu; \ + elif [ "${TARGETPLATFORM}" = "linux/amd64" ]; then \ + rustup target install x86_64-unknown-linux-gnu; \ + fi \ + && cd ~/plrust/plrustc \ +# install plrust + && ./build.sh \ + && mv ~/plrust/build/bin/plrustc ~/.cargo/bin/ \ +# install postgrestd + && cd ~/plrust/plrust \ + && PG_VER=16 \ + && if [ "${TARGETPLATFORM}" = "linux/arm64" ]; then \ + STD_TARGETS="aarch64-postgres-linux-gnu "; \ + elif [ "${TARGETPLATFORM}" = "linux/amd64" ]; then \ + STD_TARGETS="x86_64-postgres-linux-gnu "; \ + fi \ + && ./build \ + && cargo pgrx install --release --features trusted -c /usr/bin/pg_config \ + && CONFIG_FILE="/etc/postgresql/16/main/postgresql.conf" \ + && if grep -q "^shared_preload_libraries" "$CONFIG_FILE"; then \ + grep "^shared_preload_libraries" "$CONFIG_FILE" | grep -q "plrust" || \ + sed -i "s/^\(shared_preload_libraries *= *'\(.*\)'\)/shared_preload_libraries = '\2, plrust'/" "$CONFIG_FILE"; \ + else \ + echo "shared_preload_libraries = 'plrust'" >> "$CONFIG_FILE"; \ + fi \ + && echo "plrust.work_dir = '/tmp'" >> "$CONFIG_FILE" \ +# Cleanup + && rm -rf /tmp/* + +EXPOSE 5432 + +CMD ["/usr/bin/run_postgres.sh"] \ No newline at end of file diff --git a/deployment/docker/postgres16WithPLRust/naksha-pg-release/Dockerfile b/deployment/docker/postgres16WithPLRust/naksha-pg-release/Dockerfile new file mode 100644 index 0000000000..04ceef0580 --- /dev/null +++ b/deployment/docker/postgres16WithPLRust/naksha-pg-release/Dockerfile @@ -0,0 +1,15 @@ +ARG DR_NAKSHA_POSTGRES=hcr.data.here.com/naksha/postgres +ARG VERSION +FROM ${DR_NAKSHA_POSTGRES}:plrust-${VERSION} + +ADD files / + +RUN chown postgres:postgres /usr/bin/run_postgres.sh \ + && chmod 755 /usr/bin/run_postgres.sh \ + && chown -R postgres:postgres /home/postgres \ + && cd /home/postgres \ + && chown -R postgres:postgres * + +EXPOSE 5432 + +CMD ["/usr/bin/run_postgres.sh"] \ No newline at end of file diff --git a/deployment/docker/postgres16WithPLRust/naksha-pg-release/files/LICENSE b/deployment/docker/postgres16WithPLRust/naksha-pg-release/files/LICENSE new file mode 100644 index 0000000000..d645695673 --- /dev/null +++ b/deployment/docker/postgres16WithPLRust/naksha-pg-release/files/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/deployment/docker/postgres16WithPLRust/naksha-pg-release/files/home/postgres/.config/rclone/rclone.conf b/deployment/docker/postgres16WithPLRust/naksha-pg-release/files/home/postgres/.config/rclone/rclone.conf new file mode 100644 index 0000000000..a5b2490efd --- /dev/null +++ b/deployment/docker/postgres16WithPLRust/naksha-pg-release/files/home/postgres/.config/rclone/rclone.conf @@ -0,0 +1,5 @@ +[here] +type = s3 +provider = AWS +env_auth = true +region = us-east-1 diff --git a/deployment/docker/postgres16WithPLRust/naksha-pg-release/files/home/postgres/pg_hba.conf b/deployment/docker/postgres16WithPLRust/naksha-pg-release/files/home/postgres/pg_hba.conf new file mode 100644 index 0000000000..1121bdaf7d --- /dev/null +++ b/deployment/docker/postgres16WithPLRust/naksha-pg-release/files/home/postgres/pg_hba.conf @@ -0,0 +1,96 @@ +# PostgreSQL Client Authentication Configuration File +# =================================================== +# +# Refer to the "Client Authentication" section in the PostgreSQL +# documentation for a complete description of this file. A short +# synopsis follows. +# +# This file controls: which hosts are allowed to connect, how clients +# are authenticated, which PostgreSQL user names they can use, which +# databases they can access. Records take one of these forms: +# +# local DATABASE USER METHOD [OPTIONS] +# host DATABASE USER ADDRESS METHOD [OPTIONS] +# hostssl DATABASE USER ADDRESS METHOD [OPTIONS] +# hostnossl DATABASE USER ADDRESS METHOD [OPTIONS] +# hostgssenc DATABASE USER ADDRESS METHOD [OPTIONS] +# hostnogssenc DATABASE USER ADDRESS METHOD [OPTIONS] +# +# (The uppercase items must be replaced by actual values.) +# +# The first field is the connection type: "local" is a Unix-domain +# socket, "host" is either a plain or SSL-encrypted TCP/IP socket, +# "hostssl" is an SSL-encrypted TCP/IP socket, and "hostnossl" is a +# non-SSL TCP/IP socket. Similarly, "hostgssenc" uses a +# GSSAPI-encrypted TCP/IP socket, while "hostnogssenc" uses a +# non-GSSAPI socket. +# +# DATABASE can be "all", "sameuser", "samerole", "replication", a +# database name, or a comma-separated list thereof. The "all" +# keyword does not match "replication". Access to replication +# must be enabled in a separate record (see example below). +# +# USER can be "all", a user name, a group name prefixed with "+", or a +# comma-separated list thereof. In both the DATABASE and USER fields +# you can also write a file name prefixed with "@" to include names +# from a separate file. +# +# ADDRESS specifies the set of hosts the record matches. It can be a +# host name, or it is made up of an IP address and a CIDR mask that is +# an integer (between 0 and 32 (IPv4) or 128 (IPv6) inclusive) that +# specifies the number of significant bits in the mask. A host name +# that starts with a dot (.) matches a suffix of the actual host name. +# Alternatively, you can write an IP address and netmask in separate +# columns to specify the set of hosts. Instead of a CIDR-address, you +# can write "samehost" to match any of the server's own IP addresses, +# or "samenet" to match any address in any subnet that the server is +# directly connected to. +# +# METHOD can be "trust", "reject", "md5", "password", "scram-sha-256", +# "gss", "sspi", "ident", "peer", "pam", "ldap", "radius" or "cert". +# Note that "password" sends passwords in clear text; "md5" or +# "scram-sha-256" are preferred since they send encrypted passwords. +# +# OPTIONS are a set of options for the authentication in the format +# NAME=VALUE. The available options depend on the different +# authentication methods -- refer to the "Client Authentication" +# section in the documentation for a list of which options are +# available for which authentication methods. +# +# Database and user names containing spaces, commas, quotes and other +# special characters must be quoted. Quoting one of the keywords +# "all", "sameuser", "samerole" or "replication" makes the name lose +# its special character, and just match a database or username with +# that name. +# +# This file is read on server startup and when the server receives a +# SIGHUP signal. If you edit the file on a running system, you have to +# SIGHUP the server for the changes to take effect, run "pg_ctl reload", +# or execute "SELECT pg_reload_conf()". +# +# Put your actual configuration here +# ---------------------------------- +# +# If you want to allow non-local connections, you need to add more +# "host" records. In that case you will also need to make PostgreSQL +# listen on a non-local interface via the listen_addresses +# configuration parameter, or via the -i or -h command line switches. + + + + +# DO NOT DISABLE! +# If you change this first entry you will need to make sure that the +# database superuser can access the database using some other method. +# Noninteractive access to all databases is required during automatic +# maintenance (custom daily cronjobs, replication, and similar tasks). +# +# Database administrative login by Unix domain socket + +# TYPE DATABASE USER ADDRESS METHOD +local all all trust +local all all scram-sha-256 +host all all 127.0.0.1/32 md5 +host all all 10.0.0.0/8 md5 +host all all 192.168.0.0/16 md5 +host all all 172.17.0.0/16 md5 diff --git a/deployment/docker/postgres16WithPLRust/naksha-pg-release/files/home/postgres/postgresql.conf b/deployment/docker/postgres16WithPLRust/naksha-pg-release/files/home/postgres/postgresql.conf new file mode 100644 index 0000000000..390e6670de --- /dev/null +++ b/deployment/docker/postgres16WithPLRust/naksha-pg-release/files/home/postgres/postgresql.conf @@ -0,0 +1,362 @@ +# Shared configurations, include via: +# include_if_exists = '/home/postgres/common.conf' + +listen_addresses = '0.0.0.0' # what IP address(es) to listen on; + # comma-separated list of addresses; + # defaults to 'localhost'; + # '*' => All IPv4 and IPv6 + # 0.0.0.0 => All, but IPv4 only + # :: 0> All, but IPv6 only + # (change requires restart) +port = 5432 # (change requires restart) + + +log_destination = 'stderr' # Valid values are combinations of + # stderr, csvlog, jsonlog, syslog, and + # eventlog, depending on platform. + # csvlog and jsonlog require + # logging_collector to be on. +logging_collector = on +log_directory = 'log' # directory where log files are written, can be absolute or relative to PGDATA +log_filename = 'postgresql-%Y-%m-%d.log' # log file name pattern, can include strftime() escapes +log_file_mode = 0640 # creation mode for log files, +log_rotation_age = 1d # Automatic rotation of logfiles will happen after that time. 0 disables. +log_rotation_size = 1GB # Automatic rotation of logfiles will happen after that much log output. 0 disables. +log_truncate_on_rotation = off # If on, an existing log file with the + # same name as the new log file will be + # truncated rather than appended to. + # But such truncation only occurs on + # time-driven rotation, not on restarts + # or size-driven rotation. Default is + # off, meaning append to existing files + # in all cases. + +#debug_print_parse = off +#debug_print_rewritten = off +#debug_print_plan = off +#debug_pretty_print = on +log_autovacuum_min_duration = 10000 # log autovacuum activity; + # -1 disables, 0 logs all actions and + # their durations, > 0 logs only + # actions running at least this number + # of milliseconds. +log_checkpoints = on +log_connections = on +log_disconnections = on +#log_duration = off +#log_error_verbosity = default # terse, default, or verbose messages +#log_hostname = off +#log_line_prefix = '%m [%p] ' # special values: + # %a = application name + # %u = user name + # %d = database name + # %r = remote host and port + # %h = remote host + # %b = backend type + # %p = process ID + # %P = process ID of parallel group leader + # %t = timestamp without milliseconds + # %m = timestamp with milliseconds + # %n = timestamp with milliseconds (as a Unix epoch) + # %Q = query ID (0 if none or not computed) + # %i = command tag + # %e = SQL state + # %c = session ID + # %l = session line number + # %s = session start timestamp + # %v = virtual transaction ID + # %x = transaction ID (0 if none) + # %q = stop here in non-session + # processes + # %% = '%' + # e.g. '<%u%%%d> ' +#log_lock_waits = off # log lock waits >= deadlock_timeout +#log_recovery_conflict_waits = off # log standby recovery conflict waits + # >= deadlock_timeout +#log_parameter_max_length = -1 # when logging statements, limit logged + # bind-parameter values to N bytes; + # -1 means print in full, 0 disables +#log_parameter_max_length_on_error = 0 # when logging an error, limit logged + # bind-parameter values to N bytes; + # -1 means print in full, 0 disables +log_statement = 'none' # none, ddl, mod, all +#log_replication_commands = off +#log_temp_files = -1 # log temporary files equal or larger + # than the specified size in kilobytes; + # -1 disables, 0 logs all temp files +log_timezone = UTC + + +temp_tablespaces = 'temp' # a list of tablespace names, '' uses + # only default tablespace +default_transaction_isolation = 'read committed' # 'read uncommitted', 'read committed', 'repeatable read', or 'serializable' +default_transaction_read_only = off +# SET TRANSACTION READ WRITE +# https://www.postgresql.org/docs/current/sql-set-transaction.html + +random_page_cost = 1.1 +cpu_tuple_cost = 0.03 +cpu_index_tuple_cost = 0.0005 +huge_pages = try +shared_preload_libraries = 'pg_partman_bgw, pg_hint_plan, pg_cron' +# session_preload_libraries = + +datestyle = 'iso, mdy' +lc_messages = 'C.UTF-8' # locale for system error message +lc_monetary = 'C.UTF-8' # locale for monetary formatting +lc_numeric = 'C.UTF-8' # locale for number formatting +lc_time = 'C.UTF-8' # locale for time formatting + +# pg_partman +# pg_partman_bgw.interval = 3600 +# pg_partman_bgw.role = 'postgres' +# pg_partman_bgw.dbname = 'keith' + +# r6idn.metal + +# Memory/Disk +max_connections = 1024 +shared_buffers = 4GB +maintenance_work_mem = 1GB +default_statistics_target = 10000 # Sets the default statistics target, 1 to 10000 +work_mem = 512MB +dynamic_shared_memory_type = posix # the default is usually the first option + +# WAL +# To change WAL segment size on existing system, do: +# pg_resetwal -D "$PGDATA" --wal-segsize 1GB +wal_level = minimal +wal_compression = lz4 # off, pglz, lz4 (--with-zstd) or zstd (--with-zstd) +full_page_writes = off # When this parameter is on, the PostgreSQL server writes the entire content + # of each disk page to WAL during the first modification of that page after a + # checkpoint. + # This option assumes that there are none atomic writes, so that partial + # writes of a row is possible. However, we aligned the chunk-size (strip-size) + # with the row size and that makes is close to impossible to get partial writes + # for our EBS volumes. The impact of this setting with our high frequency of + # WAL log writes makes it by far to expensive, especially taking into consideration + # that we anyway have backups as snapshots on daily base. +#wal_segment_size = 1GB # The total size of a WAL segment file in bytes (defined in initdb). +wal_buffers = 1GB # The amount of shared memory used for WAL data that has not yet been written to disk (max wal_segment_size). +min_wal_size = 2GB # Minimum WAL size, at least two times wal_segment_size +max_wal_size = 16GB # Maximum WAL size, at least min_wal_size + # xlog is started when (max_wal_size / (2 + checkpoint_completion_target)) hit + # see: https://github.com/postgres/postgres/blob/REL_16_STABLE/src/backend/access/transam/xlog.c#L1947 + # #define ConvertToXSegs(x, segsize) XLogMBVarToSegs((x), (segsize)) + # ... + # static void CalculateCheckpointSegments(void) { + # target = (double) ConvertToXSegs(max_wal_size_mb, wal_segment_size) / (1.0 + CheckPointCompletionTarget); + # In a nutshell: + # max_wal_size / (1 + checkpoint_completion_target), so around 50% of max_wal_size + # This means, to ensure that we do not trigger xlog too early we need to delay it until + # the last moment, which is for max_wal_size = (shared_buffers * 1.5), resulting in xlog + # starting at (shared_buffers * 0.75) + # In our case, xlog we be trigger after around 384gb have been written + # (if network is 100% utilized, after around 16 to 20 seconds, roughly) +wal_keep_size = 0 # We do not have replicas +max_wal_senders = 0 # default is 10, prevents to set WAL to minimal +# A checkpoint moves WAL log forward and writes dirty pages. +# We want to write at least 90% of dirty shared_buffers in the checkpoint timeout +# We have 100Gbps EBS bandwidth and 200Gbps network, so theoretically, we can collect 25gb/s of dirty pages +# Assuming we want to bulk load 100 million features with 300gb (around 3kb/feature) +# - We want it to be loaded at ones and then later being written down to EBS +# - We can write 12.5gb/s to WAL and keep all dirty pages in memory +# - It will take only 24 seconds to be loaded, sp 60s is totally long enough, even for slower clients +# Assuming we need to write WAL logs and dirty pages, we have only have 50% of throughput, 6.25gb/s +# - With 6.25gb/s we can write 187.5gb in 30 seconds +checkpoint_completion_target = 0.9 +checkpoint_timeout = 60s +# wal-writer runs only when synchronous_commit=off +wal_writer_delay = 1000 +wal_writer_flush_after = 1GB +# Write dirty pages in background, reduces load to WAL writer. +# Normally, write 2 times the pages that have been newly allocated up to max-pages. +#bgwriter_delay = 1000ms +#bgwriter_lru_multiplier = 2 +bgwriter_lru_maxpages = 0 # Disable background writer, we use only checkpoints, but these more frequently +#bgwriter_flush_after = 0 +# disable explicit flush, OS shall do by itself +# write-throughput = (32*320000)/1000 = 10240 mb/s +# total pages = 256*2^30/32,000 = 8,388,608 +# write-throughput = ({page-size}*{bgwriter_lru_maxpages})/{bgwriter_delay} = around mb/s +# total pages = {shared_buffers in GiB}*2^20/{page-size} + +# Concurrency +effective_io_concurrency = 1000 # We expect always SSD +max_worker_processes = 120 +max_parallel_workers = 120 +max_parallel_workers_per_gather = 40 +max_parallel_maintenance_workers = 4 +archive_mode = off + +# Planner cost +effective_cache_size = 896GB # Sets the planner's assumption about the total size of the data caches +seq_page_cost = 1.0000 # Sets the planner's estimate of the cost of a sequentially fetched disk page +random_page_cost = 1.0500 # Sets the planner's estimate of the cost of a non sequentially fetched disk page +cpu_tuple_cost = 0.0100 # Sets the planner's estimate of the cost of processing each tuple +cpu_index_tuple_cost = 0.0001 # Sets the planner's estimate of the cost of processing each index entry during an index scan + # 1/100'th of cpu_tuple_cost, we want index to be used always +cpu_operator_cost = 0.0025 # Sets the planner's estimate of the cost of processing each operator or function call +parallel_setup_cost = 100.0 # Sets the planner's estimate of the cost of starting up worker processes for parallel query +parallel_tuple_cost = 0.0100 # Sets the planner's estimate of the cost of passing each tuple (row) from worker to leader backend +min_parallel_table_scan_size = 1MB +min_parallel_index_scan_size = 1kB + +# - Genetic Query Optimizer - + +#geqo = on +#geqo_threshold = 12 +#geqo_effort = 5 # range 1-10 +#geqo_pool_size = 0 # selects default based on effort +#geqo_generations = 0 # selects default based on effort +#geqo_selection_bias = 2.0 # range 1.5-2.0 +#geqo_seed = 0.0 # range 0.0-1.0 + +# - Other Planner Options - + +#default_statistics_target = 100 # range 1-10000 +#constraint_exclusion = partition # on, off, or partition +#cursor_tuple_fraction = 0.1 # range 0.0-1.0 +#from_collapse_limit = 8 +jit = off # allow JIT compilation +#join_collapse_limit = 8 # 1 disables collapsing of explicit + # JOIN clauses +#plan_cache_mode = auto # auto, force_generic_plan or + # force_custom_plan +#recursive_worktable_factor = 10.0 # range 0.001-1000000 + +row_security = off +#default_table_access_method = 'heap' +#default_tablespace = '' # a tablespace name, '' uses the default +default_toast_compression = 'lz4' # 'pglz' or 'lz4' +temp_tablespaces = 'temp' # a list of tablespace names, '' uses + # only default tablespace +#check_function_bodies = on +default_transaction_isolation = 'read committed' # serializable, repeatable read, read committed, read uncommitted +#default_transaction_read_only = off +#default_transaction_deferrable = off +#session_replication_role = 'origin' +statement_timeout = 0 # in milliseconds, 0 is disabled + # Abort any statement that takes more than the specified amount of time. +lock_timeout = 10s # in milliseconds, 0 is disabled +idle_in_transaction_session_timeout = 0 # in milliseconds, 0 is disabled + # Sets the maximum allowed idle time between queries, when in a transaction + # Terminate any session that has been idle (that is, waiting for a client query) + # within an open transaction for longer than the specified amount of time. +idle_session_timeout = 0 # in milliseconds, 0 is disabled + # Sets the maximum allowed idle time between queries, when not in a transaction + # Terminate any session that has been idle (that is, waiting for a client query), + # but not within an open transaction, for longer than the specified amount of time. + # If this value is specified without units, it is taken as milliseconds. +gin_pending_list_limit = 16MB # Sets the maximum size of a GIN index's pending list, which is used when fastupdate + # is enabled. If the list grows larger than this maximum size, it is cleaned up by + # moving the entries in it to the index's main GIN data structure in bulk. +#createrole_self_grant = '' # set and/or inherit + +#------------------------------------------------------------------------------ +# STATISTICS +#------------------------------------------------------------------------------ + +# - Cumulative Query and Index Statistics - + +track_activities = on # Collects information about executing commands (default=on) +track_activity_query_size = 1MB # Sets the size reserved for pg_stat_activity.query, in bytes (max 1mb) +track_counts = on # Collects statistics on database activity (default=on) + # Required for autovacuum! +track_io_timing = on # Collects timing statistics for database I/O activity (default=off) +track_wal_io_timing = on # Collects timing statistics for WAL I/O activity (default=off) +track_functions = pl # none, pl, all (default=none) + # Collects function-level statistics on database activity +stats_fetch_consistency = none # cache, none, snapshot (default=cache) + # Sets the consistency of accesses to statistics data + # When set to none, each access re-fetches counters from shared memory. + # When set to cache, the first access to statistics for an object caches + # those statistics until the end of the transaction unless + # pg_stat_clear_snapshot() is called. When set to snapshot, the first + # statistics access caches all statistics accessible in the current database, + # until the end of the transaction unless pg_stat_clear_snapshot() is called. + + +# - Monitoring - + +compute_query_id = auto # Enables in-core computation of a query identifier. Query identifiers can + # be displayed in the pg_stat_activity view, using EXPLAIN, or emitted in + # the log if configured via the log_line_prefix parameter. +# All are by default off +log_statement_stats = off # Writes cumulative performance statistics to the server log +log_parser_stats = off # Writes parser performance statistics to the server log +log_planner_stats = off # Writes planner performance statistics to the server log +log_executor_stats = off # Writes executor performance statistics to the server log + +#------------------------------------------------------------------------------ +# [AUTO]VACUUM +#------------------------------------------------------------------------------ +autovacuum = on # Enable autovacuum subprocess? 'on' + # requires track_counts to also be on. +autovacuum_max_workers = 4 # max number of autovacuum subprocesses +autovacuum_naptime = 10s # time between autovacuum runs +autovacuum_vacuum_threshold = 10000 # min number of row updates before vacuum +autovacuum_vacuum_insert_threshold = 10000 # min number of row inserts before vacuum; -1 disables insert vacuums +autovacuum_analyze_threshold = 10000 # min number of row updates before analyze +autovacuum_vacuum_scale_factor = 0.1 # fraction of table size before vacuum +autovacuum_vacuum_insert_scale_factor = 0.2 # fraction of inserts over table size before insert vacuum +autovacuum_analyze_scale_factor = 0.1 # fraction of table size before analyze +autovacuum_freeze_max_age = 1000000000 # maximum XID age before forced vacuum (default: 200000000) + # select max(age(datfrozenxid)) from pg_database; +autovacuum_multixact_freeze_max_age = 1500000000 # maximum multixact age before forced vacuum (default: 400000000) + # SELECT relname, age(relfrozenxid) as xid_age, pg_size_pretty(pg_table_size(oid)) as table_size + # FROM pg_class WHERE relkind = 'r' and pg_table_size(oid) > 1073741824 + # ORDER BY age(relfrozenxid) DESC LIMIT 20; +autovacuum_vacuum_cost_delay = 0 # milliseconds; default vacuum cost delay for autovacuum, -1 means use vacuum_cost_delay # +autovacuum_vacuum_cost_limit = 1000 # default vacuum cost limit for autovacuum, -1 means use vacuum_cost_limit + # Vacuum cost amount available before napping, for autovacuum + +# Vacuum +vacuum_freeze_min_age = 10000000 # Specifies the cutoff age (in transactions) that VACUUM should use to decide whether + # to trigger freezing of pages that have an older XID. (default: 50000000) +vacuum_multixact_freeze_min_age = 10000000 +vacuum_freeze_table_age = 800000000 # VACUUM performs an aggressive scan if the table's pg_class.relfrozenxid field has reached + # the age specified by this setting. An aggressive scan differs from a regular VACUUM in + # that it visits every page that might contain unfrozen XIDs or MXIDs, not just those that + # might contain dead tuples.(default: 150000000) + # Keep at around 80% of autovacuum_freeze_max_age +vacuum_multixact_freeze_table_age = 800000000 +vacuum_cost_delay = 0 # milliseconds; The amount of time that the process will sleep when the cost + # limit has been exceeded. If this value is specified without units, it is + # taken as milliseconds. The default value is zero, which disables the + # cost-based vacuum delay feature. Positive values enable cost-based vacuuming. +vacuum_cost_limit = 1000 # The accumulated cost that will cause the vacuuming process to sleep. +#vacuum_failsafe_age = 1600000000 +#vacuum_multixact_failsafe_age = 1600000000 + + +#------------------------------------------------------------------------------ +# LOCK MANAGEMENT +#------------------------------------------------------------------------------ + +deadlock_timeout = 10s # This is the amount of time to wait on a lock before checking to see if there is + # a deadlock condition. The check for deadlock is relatively expensive, so the + # server doesn't run it every time it waits for a lock. +max_locks_per_transaction = 4096 # min 10 (cost around 256 byte per lock, so 1 MiB/connection) +max_pred_locks_per_transaction = 4096 # min 10 (cost around 256 byte per lock, so 1 MiB/connection) +max_pred_locks_per_relation = -2 # negative values mean + # (max_pred_locks_per_transaction / -max_pred_locks_per_relation) - 1 +max_pred_locks_per_page = 16 # Sets the maximum number of predicate-locked tuples per page + # This controls how many rows on a single page can be predicate-locked before the + # lock is promoted to covering the whole page. The default is 2. + # We increase the row size by 4 times (32k instead of 8k), so increase this too + + +# Other +synchronize_seqscans = off # This allows sequential scans of large tables to synchronize with each other, so + # that concurrent scans read the same block at about the same time and hence share + # the I/O workload. + # This can result in unpredictable changes in the row ordering returned by queries + # that have no ORDER BY clause. Setting this parameter to off ensures the pre-8.3 + # behavior in which a sequential scan always starts from the beginning of the table. + # NOTE: We have enough cache (as well in the OS) so that for us order is more important! +transform_null_equals = on # Treats "expr=NULL" as "expr IS NULL" + # default is off + +hba_file = '/home/postgres/pg_hba.conf' +# include_if_exists 'r6idn.metal.conf' diff --git a/deployment/docker/postgres16WithPLRust/naksha-pg-release/files/home/postgres/r6idn.metal.conf b/deployment/docker/postgres16WithPLRust/naksha-pg-release/files/home/postgres/r6idn.metal.conf new file mode 100644 index 0000000000..dfac3bf3b1 --- /dev/null +++ b/deployment/docker/postgres16WithPLRust/naksha-pg-release/files/home/postgres/r6idn.metal.conf @@ -0,0 +1,21 @@ +# r6idn.metal + +# Memory/Disk +shared_buffers = 512GB +maintenance_work_mem = 8GB +min_wal_size = 64GB +max_wal_size = 768GB + +max_worker_processes = 400 +max_parallel_workers = 400 +max_parallel_workers_per_gather = 40 +max_parallel_maintenance_workers = 40 +autovacuum_max_workers = 40 +max_connections = 5000 + +# Sets the maximum allowed idle time between queries, when in a transaction +idle_in_transaction_session_timeout = 60s +# Sets the maximum allowed duration of any statement +statement_timeout = 5min +# Sets the maximum allowed idle time between queries, when not in a transaction +idle_session_timeout = 15min diff --git a/deployment/docker/postgres16WithPLRust/naksha-pg-release/files/usr/bin/run_postgres.sh b/deployment/docker/postgres16WithPLRust/naksha-pg-release/files/usr/bin/run_postgres.sh new file mode 100755 index 0000000000..dddf3379b2 --- /dev/null +++ b/deployment/docker/postgres16WithPLRust/naksha-pg-release/files/usr/bin/run_postgres.sh @@ -0,0 +1,92 @@ +#!/bin/bash + +if [ "$PGDATA" == "" ]; then + export PGDATA=/usr/local/pgsql/data +fi +if [ "$PGTEMP" == "" ]; then + export PGTEMP=/usr/local/pgsql/temp +fi +if [ "$PGDATABASE" == "" ]; then + export PGDATABASE="postgres" +fi +if [ "$PGUSER" == "" ]; then + export PGUSER="postgres" +fi +if [ "$PGPASSWORD" == "" ]; then + export PGPASSWORD=$(LC_CTYPE=C tr -dc A-Za-z < /dev/urandom | head -c 32 | xargs) + STORE_PG_PWD="yes" +else + STORE_PG_PWD="no" +fi + +# Setup database +mkdir -p "$PGDATA" +mkdir -p "$PGTEMP" + +chown postgres:postgres "$PGDATA" "$PGTEMP" +if [ -z "$(ls -A "$PGDATA")" ]; then + echo "$PGPASSWORD" > /home/postgres/postgres.pwd + chown postgres:postgres /home/postgres/postgres.pwd + su postgres -c "initdb --pgdata=$PGDATA --allow-group-access --locale=C.UTF-8 --locale-provider=libc --wal-segsize=1024 -U $PGUSER --pwfile=/home/postgres/postgres.pwd" + if [ $? == 0 ]; then + echo "Initialized database with password: $PG_PWD" + echo "Copy postgresql.conf to $PGDATA" + cp /home/postgres/postgresql.conf "$PGDATA"/. + echo "Start postgres" + su postgres -c "pg_ctl -D '$PGDATA' start" + sleep 1 + # Note: "postgres" is hardcoded in initdb source, therefore we need to create an additional database, if wished + if [ "postgres" != "$PGDATABASE" ]; then + echo "Create $PGDATABASE database" + su postgres -c "psql -d postgres -c \"CREATE DATABASE $PGDATABASE;\"" + fi + echo "Create temporary tablespace" + su postgres -c "psql -c \"CREATE TABLESPACE temp LOCATION '$PGTEMP';\"" + echo "Stop postgres" + su postgres -c "pg_ctl -D '$PGDATA' stop" + if [ "$STORE_PG_PWD" == "yes" ]; then + echo "Export generated password in $PGDATA/$PGUSER.pwd" + echo "$PGPASSWORD" > "$PGDATA/$PGUSER.pwd" + chown postgres:postgres "$PGDATA/$PGUSER.pwd" + fi + else + echo "Failed to initialize database" + exit 1 + fi +else + echo "Database already initialized" +fi + +#POSTMASTER_PID=$(head -n 1 "$PGDATA"/postmaster.pid) +#function clean_shutdown() { +# if ps -p "$POSTMASTER_PID" > /dev/null; then +# kill -s SIGTERM "$POSTMASTER_PID"; +# wait "$POSTMASTER_PID"; +# fi +# exit 0; +#} +#function reload_config() { +# if ps -p "$POSTMASTER_PID" > /dev/null; then +# pg_ctl reload +# fi +#} +#function check_postgres() { +# if ! ps -p "$POSTMASTER_PID" > /dev/null; then +# exit 1; +# fi +#} + +#trap "{ echo Received SIGTERM; clean_shutdown; }" SIGTERM +#trap "{ echo Received SIGINT; clean_shutdown; }" SIGINT +#trap "{ echo Received SIGHUP; reload_config; }" SIGHUP + +# Wait for signals +#while true; do +# check_postgres +# sleep 1000; +#done + +# The exec is necessary to for postgres as child so that it receives signals +# Without this, postgres will not cleanly shut down, when docker stop is invoked +echo "Start postgres" +exec su postgres -c "/usr/local/bin/postgres -D '$PGDATA'" From 3baff9179be17a370d85cc9f116f35b6140e4b0f Mon Sep 17 00:00:00 2001 From: phmai Date: Tue, 8 Apr 2025 16:05:37 +0200 Subject: [PATCH 07/13] CASL-949 adjust plrust build Signed-off-by: phmai --- .../naksha-pg-5-plrust/Dockerfile | 47 +++++++++++++------ 1 file changed, 32 insertions(+), 15 deletions(-) diff --git a/deployment/docker/postgres16WithPLRust/naksha-pg-5-plrust/Dockerfile b/deployment/docker/postgres16WithPLRust/naksha-pg-5-plrust/Dockerfile index 4fd0499704..1ea0c9188d 100644 --- a/deployment/docker/postgres16WithPLRust/naksha-pg-5-plrust/Dockerfile +++ b/deployment/docker/postgres16WithPLRust/naksha-pg-5-plrust/Dockerfile @@ -5,33 +5,46 @@ FROM ${DR_NAKSHA_POSTGRES}:pljava-${VERSION} # https://github.com/tcdi/plrust # https://plrust.io/install-plrust.html#trusted-installation-plus-cross-compilation -RUN chown postgres -R /usr/share/postgresql/16/extension/ \ - && chown postgres -R /usr/lib/postgresql/15/lib/ \ +RUN chown postgres -R "$(pg_config --sharedir)/extension" \ + && chown postgres -R "$(pg_config --pkglibdir)" USER postgres RUN cd /tmp/ \ && curl --tlsv1.3 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain stable -y \ + && source ~/.cargo/env \ && git clone https://github.com/tcdi/plrust.git \ - && rustup default 1.86.0 \ -# install pgrx - && cargo install cargo-pgrx --locked \ - && cargo pgrx init --pg16 /usr/local/bin/pg_config \ + && cd /tmp/plrust \ + && git checkout v1.2.8 \ +# temporarily adjust dependencies version to support postgres 16 \ +# https://github.com/tcdi/plrust/issues/417 + && sed -i '/^quote = "1"/a\ + litemap = { version = "=0.7.4", forced = true } \n \ + zerofrom = { version = "=0.1.5", forced = true } \n' plrust/Cargo.toml \ + && sed -i '/^pub(crate) fn cargo_toml_template/a\ + home = { version = "=0.5.9", forced = true } \n \ + litemap = { version = "=0.7.4", forced = true } \n \ + zerofrom = { version = "=0.1.5", forced = true } \n' plrust/src/user_crate/crating.rs \ + && rustup default 1.72.0 \ && rustup component add llvm-tools-preview rustc-dev \ && if [ "${TARGETPLATFORM}" = "linux/arm64" ]; then \ - rustup target install aarch64-unknown-linux-gnu; \ - elif [ "${TARGETPLATFORM}" = "linux/amd64" ]; then \ - rustup target install x86_64-unknown-linux-gnu; \ - fi \ - && cd ~/plrust/plrustc \ + rustup target install aarch64-unknown-linux-gnu; \ + elif [ "${TARGETPLATFORM}" = "linux/amd64" ]; then \ + rustup target install x86_64-unknown-linux-gnu; \ + fi \ +# && cargo build --release \ +# install pgrx + && cargo install cargo-pgrx --locked --version=0.11.0 \ + && cargo pgrx init --pg16 /usr/local/bin/pg_config \ + && cd /tmp/plrust/plrustc \ # install plrust && ./build.sh \ - && mv ~/plrust/build/bin/plrustc ~/.cargo/bin/ \ + && mv /tmp/plrust/build/bin/plrustc ~/.cargo/bin/ \ # install postgrestd - && cd ~/plrust/plrust \ + && cd /tmp/plrust/plrust \ && PG_VER=16 \ && if [ "${TARGETPLATFORM}" = "linux/arm64" ]; then \ - STD_TARGETS="aarch64-postgres-linux-gnu "; \ + STD_TARGETS="aarch64-postgres-linux-gnu"; \ elif [ "${TARGETPLATFORM}" = "linux/amd64" ]; then \ - STD_TARGETS="x86_64-postgres-linux-gnu "; \ + STD_TARGETS="x86_64-postgres-linux-gnu"; \ fi \ && ./build \ && cargo pgrx install --release --features trusted -c /usr/bin/pg_config \ @@ -43,9 +56,13 @@ RUN cd /tmp/ \ echo "shared_preload_libraries = 'plrust'" >> "$CONFIG_FILE"; \ fi \ && echo "plrust.work_dir = '/tmp'" >> "$CONFIG_FILE" \ + && chown root -R "$(pg_config --sharedir)/extension" \ + && chown root -R "$(pg_config --pkglibdir)" \ # Cleanup && rm -rf /tmp/* +USER root + EXPOSE 5432 CMD ["/usr/bin/run_postgres.sh"] \ No newline at end of file From 377394c4e12da5a34dfe39513a9d6c124e9295c2 Mon Sep 17 00:00:00 2001 From: phmai Date: Tue, 8 Apr 2025 17:45:28 +0200 Subject: [PATCH 08/13] CASL-949 adjust plrust build Signed-off-by: phmai --- .../naksha-pg-5-plrust/Dockerfile | 29 +++++++++---------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/deployment/docker/postgres16WithPLRust/naksha-pg-5-plrust/Dockerfile b/deployment/docker/postgres16WithPLRust/naksha-pg-5-plrust/Dockerfile index 1ea0c9188d..849de12161 100644 --- a/deployment/docker/postgres16WithPLRust/naksha-pg-5-plrust/Dockerfile +++ b/deployment/docker/postgres16WithPLRust/naksha-pg-5-plrust/Dockerfile @@ -5,7 +5,8 @@ FROM ${DR_NAKSHA_POSTGRES}:pljava-${VERSION} # https://github.com/tcdi/plrust # https://plrust.io/install-plrust.html#trusted-installation-plus-cross-compilation -RUN chown postgres -R "$(pg_config --sharedir)/extension" \ +RUN dnf install clang \ + && chown postgres -R "$(pg_config --sharedir)/extension" \ && chown postgres -R "$(pg_config --pkglibdir)" USER postgres RUN cd /tmp/ \ @@ -16,37 +17,35 @@ RUN cd /tmp/ \ && git checkout v1.2.8 \ # temporarily adjust dependencies version to support postgres 16 \ # https://github.com/tcdi/plrust/issues/417 - && sed -i '/^quote = "1"/a\ - litemap = { version = "=0.7.4", forced = true } \n \ - zerofrom = { version = "=0.1.5", forced = true } \n' plrust/Cargo.toml \ - && sed -i '/^pub(crate) fn cargo_toml_template/a\ - home = { version = "=0.5.9", forced = true } \n \ - litemap = { version = "=0.7.4", forced = true } \n \ - zerofrom = { version = "=0.1.5", forced = true } \n' plrust/src/user_crate/crating.rs \ - && rustup default 1.72.0 \ +# https://github.com/tcdi/plrust/issues/418 +# && sed -i '/^quote = "1"/a\ +# litemap = { version = "=0.7.4", forced = true } \n \ +# zerofrom = { version = "=0.1.5", forced = true } \n' plrust/Cargo.toml \ +# && sed -i '/^pub(crate) fn cargo_toml_template/a\ +# home = { version = "=0.5.9", forced = true } \n \ +# litemap = { version = "=0.7.4", forced = true } \n \ +# zerofrom = { version = "=0.1.5", forced = true } \n' plrust/src/user_crate/crating.rs \ && rustup component add llvm-tools-preview rustc-dev \ && if [ "${TARGETPLATFORM}" = "linux/arm64" ]; then \ rustup target install aarch64-unknown-linux-gnu; \ elif [ "${TARGETPLATFORM}" = "linux/amd64" ]; then \ rustup target install x86_64-unknown-linux-gnu; \ fi \ -# && cargo build --release \ # install pgrx && cargo install cargo-pgrx --locked --version=0.11.0 \ - && cargo pgrx init --pg16 /usr/local/bin/pg_config \ + && cargo pgrx init --pg16 "$(pg_config --sharedir)/pg_config" \ && cd /tmp/plrust/plrustc \ # install plrust && ./build.sh \ && mv /tmp/plrust/build/bin/plrustc ~/.cargo/bin/ \ # install postgrestd && cd /tmp/plrust/plrust \ - && PG_VER=16 \ +# && PG_VER=16 \ && if [ "${TARGETPLATFORM}" = "linux/arm64" ]; then \ - STD_TARGETS="aarch64-postgres-linux-gnu"; \ + STD_TARGETS="aarch64-postgres-linux-gnu" ./build; \ elif [ "${TARGETPLATFORM}" = "linux/amd64" ]; then \ - STD_TARGETS="x86_64-postgres-linux-gnu"; \ + STD_TARGETS="x86_64-postgres-linux-gnu" ./build; \ fi \ - && ./build \ && cargo pgrx install --release --features trusted -c /usr/bin/pg_config \ && CONFIG_FILE="/etc/postgresql/16/main/postgresql.conf" \ && if grep -q "^shared_preload_libraries" "$CONFIG_FILE"; then \ From 6be5a6e0d3bb88580687f9c96384f5f7cdd6e5c4 Mon Sep 17 00:00:00 2001 From: phmai Date: Wed, 9 Apr 2025 11:42:47 +0200 Subject: [PATCH 09/13] CASL-949 adjust plrust build Signed-off-by: phmai --- .../naksha-pg-5-plrust/Dockerfile | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/deployment/docker/postgres16WithPLRust/naksha-pg-5-plrust/Dockerfile b/deployment/docker/postgres16WithPLRust/naksha-pg-5-plrust/Dockerfile index 849de12161..ae858bc329 100644 --- a/deployment/docker/postgres16WithPLRust/naksha-pg-5-plrust/Dockerfile +++ b/deployment/docker/postgres16WithPLRust/naksha-pg-5-plrust/Dockerfile @@ -10,8 +10,10 @@ RUN dnf install clang \ && chown postgres -R "$(pg_config --pkglibdir)" USER postgres RUN cd /tmp/ \ +# install rust via rustup && curl --tlsv1.3 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain stable -y \ && source ~/.cargo/env \ +# install PL Rust from source && git clone https://github.com/tcdi/plrust.git \ && cd /tmp/plrust \ && git checkout v1.2.8 \ @@ -31,37 +33,34 @@ RUN cd /tmp/ \ elif [ "${TARGETPLATFORM}" = "linux/amd64" ]; then \ rustup target install x86_64-unknown-linux-gnu; \ fi \ -# install pgrx - && cargo install cargo-pgrx --locked --version=0.11.0 \ - && cargo pgrx init --pg16 "$(pg_config --sharedir)/pg_config" \ + && cargo pgrx init --pg16 "$(pg_config --bindir)/pg_config" \ && cd /tmp/plrust/plrustc \ # install plrust && ./build.sh \ && mv /tmp/plrust/build/bin/plrustc ~/.cargo/bin/ \ # install postgrestd && cd /tmp/plrust/plrust \ -# && PG_VER=16 \ && if [ "${TARGETPLATFORM}" = "linux/arm64" ]; then \ STD_TARGETS="aarch64-postgres-linux-gnu" ./build; \ elif [ "${TARGETPLATFORM}" = "linux/amd64" ]; then \ STD_TARGETS="x86_64-postgres-linux-gnu" ./build; \ fi \ - && cargo pgrx install --release --features trusted -c /usr/bin/pg_config \ - && CONFIG_FILE="/etc/postgresql/16/main/postgresql.conf" \ - && if grep -q "^shared_preload_libraries" "$CONFIG_FILE"; then \ - grep "^shared_preload_libraries" "$CONFIG_FILE" | grep -q "plrust" || \ - sed -i "s/^\(shared_preload_libraries *= *'\(.*\)'\)/shared_preload_libraries = '\2, plrust'/" "$CONFIG_FILE"; \ + && cargo pgrx init --pg16 "$(pg_config --bindir)/pg_config" \ + && cargo pgrx install --release --features trusted -c "$(pg_config --bindir)/pg_config" +ENV POSTGRESQL_CONF="/usr/local/pgsql/data/postgresql.conf" \ +RUN if grep -q "^shared_preload_libraries" "$POSTGRESQL_CONF"; then \ + grep "^shared_preload_libraries" "$POSTGRESQL_CONF" | grep -q "plrust" || \ + sed -i "s/^\(shared_preload_libraries *= *'\(.*\)'\)/shared_preload_libraries = '\2, plrust'/" "$POSTGRESQL_CONF"; \ else \ - echo "shared_preload_libraries = 'plrust'" >> "$CONFIG_FILE"; \ + echo "shared_preload_libraries = 'plrust'" >> "$POSTGRESQL_CONF"; \ fi \ - && echo "plrust.work_dir = '/tmp'" >> "$CONFIG_FILE" \ - && chown root -R "$(pg_config --sharedir)/extension" \ + && echo "plrust.work_dir = '/tmp'" >> "$POSTGRESQL_CONF" \ +USER root +RUN chown root -R "$(pg_config --sharedir)/extension" \ && chown root -R "$(pg_config --pkglibdir)" \ # Cleanup && rm -rf /tmp/* -USER root - EXPOSE 5432 CMD ["/usr/bin/run_postgres.sh"] \ No newline at end of file From 82ec44ce298bbde56f630d1525a1f0b084bc40d8 Mon Sep 17 00:00:00 2001 From: phmai Date: Wed, 9 Apr 2025 12:08:00 +0200 Subject: [PATCH 10/13] CASL-949 adjust plrust build Signed-off-by: phmai --- .../postgres16WithPLRust/naksha-pg-5-plrust/Dockerfile | 8 -------- .../naksha-pg-release/files/home/postgres/postgresql.conf | 4 +++- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/deployment/docker/postgres16WithPLRust/naksha-pg-5-plrust/Dockerfile b/deployment/docker/postgres16WithPLRust/naksha-pg-5-plrust/Dockerfile index ae858bc329..a986abe483 100644 --- a/deployment/docker/postgres16WithPLRust/naksha-pg-5-plrust/Dockerfile +++ b/deployment/docker/postgres16WithPLRust/naksha-pg-5-plrust/Dockerfile @@ -47,14 +47,6 @@ RUN cd /tmp/ \ fi \ && cargo pgrx init --pg16 "$(pg_config --bindir)/pg_config" \ && cargo pgrx install --release --features trusted -c "$(pg_config --bindir)/pg_config" -ENV POSTGRESQL_CONF="/usr/local/pgsql/data/postgresql.conf" \ -RUN if grep -q "^shared_preload_libraries" "$POSTGRESQL_CONF"; then \ - grep "^shared_preload_libraries" "$POSTGRESQL_CONF" | grep -q "plrust" || \ - sed -i "s/^\(shared_preload_libraries *= *'\(.*\)'\)/shared_preload_libraries = '\2, plrust'/" "$POSTGRESQL_CONF"; \ - else \ - echo "shared_preload_libraries = 'plrust'" >> "$POSTGRESQL_CONF"; \ - fi \ - && echo "plrust.work_dir = '/tmp'" >> "$POSTGRESQL_CONF" \ USER root RUN chown root -R "$(pg_config --sharedir)/extension" \ && chown root -R "$(pg_config --pkglibdir)" \ diff --git a/deployment/docker/postgres16WithPLRust/naksha-pg-release/files/home/postgres/postgresql.conf b/deployment/docker/postgres16WithPLRust/naksha-pg-release/files/home/postgres/postgresql.conf index 390e6670de..a1ff99500d 100644 --- a/deployment/docker/postgres16WithPLRust/naksha-pg-release/files/home/postgres/postgresql.conf +++ b/deployment/docker/postgres16WithPLRust/naksha-pg-release/files/home/postgres/postgresql.conf @@ -98,7 +98,7 @@ random_page_cost = 1.1 cpu_tuple_cost = 0.03 cpu_index_tuple_cost = 0.0005 huge_pages = try -shared_preload_libraries = 'pg_partman_bgw, pg_hint_plan, pg_cron' +shared_preload_libraries = 'pg_partman_bgw, pg_hint_plan, pg_cron, plrust' # session_preload_libraries = datestyle = 'iso, mdy' @@ -360,3 +360,5 @@ transform_null_equals = on # Treats "expr=NULL" as "expr IS NUL hba_file = '/home/postgres/pg_hba.conf' # include_if_exists 'r6idn.metal.conf' + +plrust.work_dir = '/tmp' \ No newline at end of file From f92da8a5cd1e9517d995aad804c73d073ca2ea27 Mon Sep 17 00:00:00 2001 From: phmai Date: Wed, 9 Apr 2025 17:35:07 +0200 Subject: [PATCH 11/13] CASL-949 adjust plrust build Signed-off-by: phmai --- .../naksha-pg-5-plrust/Dockerfile | 22 ++++++++++--------- .../files/home/postgres/postgresql.conf | 3 ++- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/deployment/docker/postgres16WithPLRust/naksha-pg-5-plrust/Dockerfile b/deployment/docker/postgres16WithPLRust/naksha-pg-5-plrust/Dockerfile index a986abe483..887cf47ccf 100644 --- a/deployment/docker/postgres16WithPLRust/naksha-pg-5-plrust/Dockerfile +++ b/deployment/docker/postgres16WithPLRust/naksha-pg-5-plrust/Dockerfile @@ -5,7 +5,7 @@ FROM ${DR_NAKSHA_POSTGRES}:pljava-${VERSION} # https://github.com/tcdi/plrust # https://plrust.io/install-plrust.html#trusted-installation-plus-cross-compilation -RUN dnf install clang \ +RUN dnf install -y clang \ && chown postgres -R "$(pg_config --sharedir)/extension" \ && chown postgres -R "$(pg_config --pkglibdir)" USER postgres @@ -20,24 +20,26 @@ RUN cd /tmp/ \ # temporarily adjust dependencies version to support postgres 16 \ # https://github.com/tcdi/plrust/issues/417 # https://github.com/tcdi/plrust/issues/418 -# && sed -i '/^quote = "1"/a\ -# litemap = { version = "=0.7.4", forced = true } \n \ -# zerofrom = { version = "=0.1.5", forced = true } \n' plrust/Cargo.toml \ -# && sed -i '/^pub(crate) fn cargo_toml_template/a\ -# home = { version = "=0.5.9", forced = true } \n \ -# litemap = { version = "=0.7.4", forced = true } \n \ -# zerofrom = { version = "=0.1.5", forced = true } \n' plrust/src/user_crate/crating.rs \ + && sed -i '/^omnipath = "0.1.6"/a\ + litemap = { version = "=0.7.4", forced = true } \n \ + zerofrom = { version = "=0.1.5", forced = true } \n' plrust/Cargo.toml \ + && sed -i '/^pgrx = { version = trusted_pgrx_version, package = "plrust-trusted-pgrx" }/a\ + home = { version = "=0.5.9", forced = true } \n \ + litemap = { version = "=0.7.4", forced = true } \n \ + zerofrom = { version = "=0.1.5", forced = true } \n' plrust/src/user_crate/crating.rs \ + && rustup default 1.72.0 \ && rustup component add llvm-tools-preview rustc-dev \ && if [ "${TARGETPLATFORM}" = "linux/arm64" ]; then \ rustup target install aarch64-unknown-linux-gnu; \ elif [ "${TARGETPLATFORM}" = "linux/amd64" ]; then \ rustup target install x86_64-unknown-linux-gnu; \ fi \ - && cargo pgrx init --pg16 "$(pg_config --bindir)/pg_config" \ + && cargo install cargo-pgrx --locked --version=0.11.0 \ && cd /tmp/plrust/plrustc \ # install plrust && ./build.sh \ && mv /tmp/plrust/build/bin/plrustc ~/.cargo/bin/ \ + && cargo pgrx init --pg16 "$(pg_config --bindir)/pg_config" \ # install postgrestd && cd /tmp/plrust/plrust \ && if [ "${TARGETPLATFORM}" = "linux/arm64" ]; then \ @@ -46,7 +48,7 @@ RUN cd /tmp/ \ STD_TARGETS="x86_64-postgres-linux-gnu" ./build; \ fi \ && cargo pgrx init --pg16 "$(pg_config --bindir)/pg_config" \ - && cargo pgrx install --release --features trusted -c "$(pg_config --bindir)/pg_config" + && cargo pgrx install --release --features trusted USER root RUN chown root -R "$(pg_config --sharedir)/extension" \ && chown root -R "$(pg_config --pkglibdir)" \ diff --git a/deployment/docker/postgres16WithPLRust/naksha-pg-release/files/home/postgres/postgresql.conf b/deployment/docker/postgres16WithPLRust/naksha-pg-release/files/home/postgres/postgresql.conf index a1ff99500d..3572450b68 100644 --- a/deployment/docker/postgres16WithPLRust/naksha-pg-release/files/home/postgres/postgresql.conf +++ b/deployment/docker/postgres16WithPLRust/naksha-pg-release/files/home/postgres/postgresql.conf @@ -361,4 +361,5 @@ transform_null_equals = on # Treats "expr=NULL" as "expr IS NUL hba_file = '/home/postgres/pg_hba.conf' # include_if_exists 'r6idn.metal.conf' -plrust.work_dir = '/tmp' \ No newline at end of file +plrust.work_dir = '/tmp' +plrust.path_override = '/home/postgres/.cargo/bin' \ No newline at end of file From d36666db48441b1d9ac28e549534bf9a61842837 Mon Sep 17 00:00:00 2001 From: phmai Date: Thu, 10 Apr 2025 11:50:34 +0200 Subject: [PATCH 12/13] CASL-949 adjust plrust build Signed-off-by: phmai --- .../docker/postgres16WithPLRust/naksha-pg-5-plrust/Dockerfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/deployment/docker/postgres16WithPLRust/naksha-pg-5-plrust/Dockerfile b/deployment/docker/postgres16WithPLRust/naksha-pg-5-plrust/Dockerfile index 887cf47ccf..b5e95d2d23 100644 --- a/deployment/docker/postgres16WithPLRust/naksha-pg-5-plrust/Dockerfile +++ b/deployment/docker/postgres16WithPLRust/naksha-pg-5-plrust/Dockerfile @@ -11,7 +11,7 @@ RUN dnf install -y clang \ USER postgres RUN cd /tmp/ \ # install rust via rustup - && curl --tlsv1.3 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain stable -y \ + && curl --tlsv1.3 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain "1.72.0" -y \ && source ~/.cargo/env \ # install PL Rust from source && git clone https://github.com/tcdi/plrust.git \ @@ -27,7 +27,6 @@ RUN cd /tmp/ \ home = { version = "=0.5.9", forced = true } \n \ litemap = { version = "=0.7.4", forced = true } \n \ zerofrom = { version = "=0.1.5", forced = true } \n' plrust/src/user_crate/crating.rs \ - && rustup default 1.72.0 \ && rustup component add llvm-tools-preview rustc-dev \ && if [ "${TARGETPLATFORM}" = "linux/arm64" ]; then \ rustup target install aarch64-unknown-linux-gnu; \ From e00a0f202b3cf9453b15b3a99d26f8a95a39702f Mon Sep 17 00:00:00 2001 From: phmai Date: Wed, 7 May 2025 12:03:18 +0200 Subject: [PATCH 13/13] CASL-949 disabled settings that might be relevant later Signed-off-by: phmai --- .../postgres16WithPLRust/naksha-pg-5-plrust/Dockerfile | 7 +++---- .../naksha-pg-release/files/home/postgres/postgresql.conf | 3 ++- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/deployment/docker/postgres16WithPLRust/naksha-pg-5-plrust/Dockerfile b/deployment/docker/postgres16WithPLRust/naksha-pg-5-plrust/Dockerfile index b5e95d2d23..751352977f 100644 --- a/deployment/docker/postgres16WithPLRust/naksha-pg-5-plrust/Dockerfile +++ b/deployment/docker/postgres16WithPLRust/naksha-pg-5-plrust/Dockerfile @@ -17,7 +17,7 @@ RUN cd /tmp/ \ && git clone https://github.com/tcdi/plrust.git \ && cd /tmp/plrust \ && git checkout v1.2.8 \ -# temporarily adjust dependencies version to support postgres 16 \ +# temporarily adjust dependencies version to support postgres 16, relevant for v1.2.8 # https://github.com/tcdi/plrust/issues/417 # https://github.com/tcdi/plrust/issues/418 && sed -i '/^omnipath = "0.1.6"/a\ @@ -34,11 +34,11 @@ RUN cd /tmp/ \ rustup target install x86_64-unknown-linux-gnu; \ fi \ && cargo install cargo-pgrx --locked --version=0.11.0 \ + && cargo pgrx init --pg16 "$(pg_config --bindir)/pg_config" \ && cd /tmp/plrust/plrustc \ # install plrust && ./build.sh \ && mv /tmp/plrust/build/bin/plrustc ~/.cargo/bin/ \ - && cargo pgrx init --pg16 "$(pg_config --bindir)/pg_config" \ # install postgrestd && cd /tmp/plrust/plrust \ && if [ "${TARGETPLATFORM}" = "linux/arm64" ]; then \ @@ -46,13 +46,12 @@ RUN cd /tmp/ \ elif [ "${TARGETPLATFORM}" = "linux/amd64" ]; then \ STD_TARGETS="x86_64-postgres-linux-gnu" ./build; \ fi \ - && cargo pgrx init --pg16 "$(pg_config --bindir)/pg_config" \ && cargo pgrx install --release --features trusted USER root RUN chown root -R "$(pg_config --sharedir)/extension" \ && chown root -R "$(pg_config --pkglibdir)" \ # Cleanup - && rm -rf /tmp/* + && rm -rf /tmp/plrust EXPOSE 5432 diff --git a/deployment/docker/postgres16WithPLRust/naksha-pg-release/files/home/postgres/postgresql.conf b/deployment/docker/postgres16WithPLRust/naksha-pg-release/files/home/postgres/postgresql.conf index 3572450b68..5526bbc953 100644 --- a/deployment/docker/postgres16WithPLRust/naksha-pg-release/files/home/postgres/postgresql.conf +++ b/deployment/docker/postgres16WithPLRust/naksha-pg-release/files/home/postgres/postgresql.conf @@ -362,4 +362,5 @@ hba_file = '/home/postgres/pg_hba.conf' # include_if_exists 'r6idn.metal.conf' plrust.work_dir = '/tmp' -plrust.path_override = '/home/postgres/.cargo/bin' \ No newline at end of file +plrust.path_override = '/home/postgres/.cargo/bin' +#plrust.compilation_targets = 'x86_64, aarch64' \ No newline at end of file