From 2707d209c11c0ef6f3a96c1d1101d6772d614738 Mon Sep 17 00:00:00 2001 From: Bryan Date: Fri, 23 Jan 2026 17:34:08 +0800 Subject: [PATCH 1/4] feat: add pg_textsearch extension --- pg_textsearch/Dockerfile | 50 +++++++++++++++++ pg_textsearch/README.md | 107 +++++++++++++++++++++++++++++++++++++ pg_textsearch/metadata.hcl | 23 ++++++++ 3 files changed, 180 insertions(+) create mode 100644 pg_textsearch/Dockerfile create mode 100644 pg_textsearch/README.md create mode 100644 pg_textsearch/metadata.hcl diff --git a/pg_textsearch/Dockerfile b/pg_textsearch/Dockerfile new file mode 100644 index 0000000..0cf1635 --- /dev/null +++ b/pg_textsearch/Dockerfile @@ -0,0 +1,50 @@ +# SPDX-FileCopyrightText: Copyright © contributors to CloudNativePG, established as CloudNativePG a Series of LF Projects, LLC. +# SPDX-License-Identifier: Apache-2.0 + + +ARG BASE=ghcr.io/cloudnative-pg/postgresql:18-minimal-trixie +FROM $BASE AS builder + +ARG PG_MAJOR +ARG EXT_VERSION + +USER 0 + +# TODO: Remove this comment block after customizing the Dockerfile +# Instructions: +# 1. Remove all TODO comment blocks after completing the customization. +# 2. Uncomment and customize the COPY/RUN commands below. +# 3. If your extension requires additional system libraries, ensure they are +# copied to /lib. + +# Install extension via `apt-get` +# RUN apt-get update && apt-get install -y --no-install-recommends \ +# "postgresql-${PG_MAJOR}-pg_textsearch=${EXT_VERSION}" + +FROM scratch +ARG PG_MAJOR + +# Licenses +# TODO: Uncomment and customize the COPY command below +# Including license files is essential for legal compliance and transparency. +# It ensures proper attribution to original authors, fulfills open source license +# requirements, and enables automated compliance scanning tools to verify licensing. +# COPY --from=builder /usr/share/doc/postgresql-${PG_MAJOR}-pg_textsearch/copyright /licenses/postgresql-${PG_MAJOR}-pg_textsearch/ + +# Libraries +# TODO: Uncomment and customize the COPY command below +# Include the extension's shared objects and related dependencies under the /lib directory. +# CNPG will configure PostgreSQL to locate these libraries at runtime by configuring +# the "dynamic_library_path" GUC to include this path. +# For more details, see: https://cloudnative-pg.io/docs/current/imagevolume_extensions#how-it-works +# COPY --from=builder /usr/lib/postgresql/${PG_MAJOR}/lib/pg_textsearch* /lib/ + +# Share +# TODO: Uncomment and customize the COPY command below +# Include the extension's SQL scripts and control files under the /share/extension directory. +# CNPG will configure PostgreSQL to include this path via the "extension_control_path" GUC to +# seamlessly find and manage the current extension. +# For more details, see: https://cloudnative-pg.io/docs/current/imagevolume_extensions#how-it-works +# COPY --from=builder /usr/share/postgresql/${PG_MAJOR}/extension/pg_textsearch* /share/extension/ + +USER 65532:65532 diff --git a/pg_textsearch/README.md b/pg_textsearch/README.md new file mode 100644 index 0000000..60f65fb --- /dev/null +++ b/pg_textsearch/README.md @@ -0,0 +1,107 @@ +# Pg_textsearch + + + + +The pg_textsearch PostgreSQL extension provides [describe the main functionality +here]. For more information, see the [official documentation](https://example.com). + +## Usage + + + +### 1. Add the pg_textsearch extension image to your Cluster + +Define the `pg_textsearch` extension under the `postgresql.extensions` section of +your `Cluster` resource. For example: + +```yaml +apiVersion: postgresql.cnpg.io/v1 +kind: Cluster +metadata: + name: cluster-pg_textsearch +spec: + imageName: ghcr.io/cloudnative-pg/postgresql:18-minimal-trixie + instances: 1 + + storage: + size: 1Gi + + postgresql: + extensions: + - name: pg_textsearch + image: + # renovate: suite=trixie-pgdg depName=postgresql-18-pg_textsearch + reference: ghcr.io/cloudnative-pg/pg_textsearch:1.0-18-trixie +``` + +### 2. Enable the extension in a database + +You can install `pg_textsearch` in a specific database by creating or updating a +`Database` resource. For example, to enable it in the `app` database: + +```yaml +apiVersion: postgresql.cnpg.io/v1 +kind: Database +metadata: + name: cluster-pg_textsearch-app +spec: + name: app + owner: app + cluster: + name: cluster-pg_textsearch + extensions: + - name: pg_textsearch + # renovate: suite=trixie-pgdg depName=postgresql-18-pg_textsearch + version: '1.0' +``` + +### 3. Verify installation + +Once the database is ready, connect to it with `psql` and run: + +```sql +\dx +``` + +You should see `pg_textsearch` listed among the installed extensions. + +## Contributors + +This extension is maintained by: + +- FirstName LastName (@GitHub_Handle) + +The maintainers are responsible for: + +- Monitoring upstream releases and security vulnerabilities. +- Ensuring compatibility with supported PostgreSQL versions. +- Reviewing and merging contributions specific to this extension's container + image and lifecycle. + +--- + +## Licenses and Copyright + +This container image contains software that may be licensed under various +open-source licenses. + +All relevant license and copyright information for the `pg_textsearch` extension +and its dependencies are bundled within the image at: + +```text +/licenses/ +``` + +By using this image, you agree to comply with the terms of the licenses +contained therein. diff --git a/pg_textsearch/metadata.hcl b/pg_textsearch/metadata.hcl new file mode 100644 index 0000000..1a188de --- /dev/null +++ b/pg_textsearch/metadata.hcl @@ -0,0 +1,23 @@ +# SPDX-FileCopyrightText: Copyright © contributors to CloudNativePG, established as CloudNativePG a Series of LF Projects, LLC. +# SPDX-License-Identifier: Apache-2.0 +metadata = { + name = "pg_textsearch" + sql_name = "pg_textsearch" + image_name = "pg_textsearch" + shared_preload_libraries = [] + extension_control_path = [] + dynamic_library_path = [] + ld_library_path = [] + auto_update_os_libs = false + + versions = { + trixie = { + // renovate: suite=trixie-pgdg depName=postgresql-18-pg_textsearch + "18" = "" + } + bookworm = { + // renovate: suite=bookworm-pgdg depName=postgresql-18-pg_textsearch + "18" = "" + } + } +} From c1c9488493c281503df8afa7ff620d58dcdfa539 Mon Sep 17 00:00:00 2001 From: Bryan Date: Fri, 23 Jan 2026 17:54:18 +0800 Subject: [PATCH 2/4] implement --- pg_textsearch/Dockerfile | 54 ++++++++++++++++---------------------- pg_textsearch/metadata.hcl | 4 +-- 2 files changed, 24 insertions(+), 34 deletions(-) diff --git a/pg_textsearch/Dockerfile b/pg_textsearch/Dockerfile index 0cf1635..4c67678 100644 --- a/pg_textsearch/Dockerfile +++ b/pg_textsearch/Dockerfile @@ -7,44 +7,34 @@ FROM $BASE AS builder ARG PG_MAJOR ARG EXT_VERSION +ARG TARGETARCH USER 0 -# TODO: Remove this comment block after customizing the Dockerfile -# Instructions: -# 1. Remove all TODO comment blocks after completing the customization. -# 2. Uncomment and customize the COPY/RUN commands below. -# 3. If your extension requires additional system libraries, ensure they are -# copied to /lib. - -# Install extension via `apt-get` -# RUN apt-get update && apt-get install -y --no-install-recommends \ -# "postgresql-${PG_MAJOR}-pg_textsearch=${EXT_VERSION}" +RUN set -eux; \ + apt-get update; \ + apt-get install -y --no-install-recommends ca-certificates wget unzip dpkg; \ + case "${TARGETARCH}" in amd64|arm64) ;; *) echo "Unsupported TARGETARCH=${TARGETARCH}" >&2; exit 1 ;; esac; \ + ZIP_URL="https://github.com/timescale/pg_textsearch/releases/download/v${EXT_VERSION}/pg-textsearch-v${EXT_VERSION}-pg${PG_MAJOR}-${TARGETARCH}.zip"; \ + DEB_FILE="pg-textsearch-postgresql-${PG_MAJOR}_${EXT_VERSION}-1_${TARGETARCH}.deb"; \ + LICENSE_TGZ_URL="https://github.com/timescale/pg_textsearch/releases/download/v${EXT_VERSION}/pg_textsearch-${EXT_VERSION}.tar.gz"; \ + mkdir -p /tmp/pg_textsearch && cd /tmp/pg_textsearch; \ + wget -O pg_textsearch.zip "$ZIP_URL"; \ + unzip -q pg_textsearch.zip "$DEB_FILE"; \ + dpkg-deb -x "./$DEB_FILE" /tmp/pkgroot; \ + mkdir -p /out/lib /out/share/extension "/out/licenses/pg-textsearch-postgresql-${PG_MAJOR}"; \ + cp -a "/tmp/pkgroot/usr/lib/postgresql/${PG_MAJOR}/lib/pg_textsearch"* /out/lib/; \ + cp -a "/tmp/pkgroot/usr/share/postgresql/${PG_MAJOR}/extension/pg_textsearch"* /out/share/extension/; \ + wget -qO- "$LICENSE_TGZ_URL" | tar -xzO "pg_textsearch-${EXT_VERSION}/LICENSE" > "/out/licenses/pg-textsearch-postgresql-${PG_MAJOR}/copyright"; \ + cd /; \ + rm -rf /tmp/pg_textsearch; \ + rm -rf /var/lib/apt/lists/* FROM scratch ARG PG_MAJOR -# Licenses -# TODO: Uncomment and customize the COPY command below -# Including license files is essential for legal compliance and transparency. -# It ensures proper attribution to original authors, fulfills open source license -# requirements, and enables automated compliance scanning tools to verify licensing. -# COPY --from=builder /usr/share/doc/postgresql-${PG_MAJOR}-pg_textsearch/copyright /licenses/postgresql-${PG_MAJOR}-pg_textsearch/ - -# Libraries -# TODO: Uncomment and customize the COPY command below -# Include the extension's shared objects and related dependencies under the /lib directory. -# CNPG will configure PostgreSQL to locate these libraries at runtime by configuring -# the "dynamic_library_path" GUC to include this path. -# For more details, see: https://cloudnative-pg.io/docs/current/imagevolume_extensions#how-it-works -# COPY --from=builder /usr/lib/postgresql/${PG_MAJOR}/lib/pg_textsearch* /lib/ - -# Share -# TODO: Uncomment and customize the COPY command below -# Include the extension's SQL scripts and control files under the /share/extension directory. -# CNPG will configure PostgreSQL to include this path via the "extension_control_path" GUC to -# seamlessly find and manage the current extension. -# For more details, see: https://cloudnative-pg.io/docs/current/imagevolume_extensions#how-it-works -# COPY --from=builder /usr/share/postgresql/${PG_MAJOR}/extension/pg_textsearch* /share/extension/ +COPY --from=builder /out/licenses/pg-textsearch-postgresql-${PG_MAJOR}/copyright /licenses/pg-textsearch-postgresql-${PG_MAJOR}/ +COPY --from=builder /out/lib/pg_textsearch* /lib/ +COPY --from=builder /out/share/extension/pg_textsearch* /share/extension/ USER 65532:65532 diff --git a/pg_textsearch/metadata.hcl b/pg_textsearch/metadata.hcl index 1a188de..1552e24 100644 --- a/pg_textsearch/metadata.hcl +++ b/pg_textsearch/metadata.hcl @@ -13,11 +13,11 @@ metadata = { versions = { trixie = { // renovate: suite=trixie-pgdg depName=postgresql-18-pg_textsearch - "18" = "" + "18" = "0.4.1" } bookworm = { // renovate: suite=bookworm-pgdg depName=postgresql-18-pg_textsearch - "18" = "" + "18" = "0.4.1" } } } From 03e8d748f2dd2709ee27fe920e7a25ee294cb59b Mon Sep 17 00:00:00 2001 From: Bryan Date: Fri, 23 Jan 2026 18:02:16 +0800 Subject: [PATCH 3/4] update README --- pg_textsearch/README.md | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/pg_textsearch/README.md b/pg_textsearch/README.md index 60f65fb..a0a8673 100644 --- a/pg_textsearch/README.md +++ b/pg_textsearch/README.md @@ -1,25 +1,11 @@ -# Pg_textsearch - +# PgTextsearch - -The pg_textsearch PostgreSQL extension provides [describe the main functionality -here]. For more information, see the [official documentation](https://example.com). +[pg_textsearch](https://github.com/timescale/pg_textsearch) is an extension that adds +**ranked full-text search (BM25)** to PostgreSQL. ## Usage - - ### 1. Add the pg_textsearch extension image to your Cluster Define the `pg_textsearch` extension under the `postgresql.extensions` section of @@ -42,7 +28,7 @@ spec: - name: pg_textsearch image: # renovate: suite=trixie-pgdg depName=postgresql-18-pg_textsearch - reference: ghcr.io/cloudnative-pg/pg_textsearch:1.0-18-trixie + reference: ghcr.io/cloudnative-pg/pg_textsearch:0.4.1-18-trixie ``` ### 2. Enable the extension in a database @@ -63,7 +49,7 @@ spec: extensions: - name: pg_textsearch # renovate: suite=trixie-pgdg depName=postgresql-18-pg_textsearch - version: '1.0' + version: '0.4.1' ``` ### 3. Verify installation @@ -80,7 +66,7 @@ You should see `pg_textsearch` listed among the installed extensions. This extension is maintained by: -- FirstName LastName (@GitHub_Handle) +- Bryan Wong (@ImSingee) The maintainers are responsible for: From 85ee90a39086244b55c9be8325f2b7a73d109379 Mon Sep 17 00:00:00 2001 From: Bryan Date: Sat, 24 Jan 2026 00:17:31 +0800 Subject: [PATCH 4/4] update README --- pg_textsearch/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pg_textsearch/README.md b/pg_textsearch/README.md index a0a8673..f0eb232 100644 --- a/pg_textsearch/README.md +++ b/pg_textsearch/README.md @@ -15,7 +15,7 @@ your `Cluster` resource. For example: apiVersion: postgresql.cnpg.io/v1 kind: Cluster metadata: - name: cluster-pg_textsearch + name: cluster-pg-textsearch spec: imageName: ghcr.io/cloudnative-pg/postgresql:18-minimal-trixie instances: 1 @@ -25,7 +25,7 @@ spec: postgresql: extensions: - - name: pg_textsearch + - name: pg-textsearch image: # renovate: suite=trixie-pgdg depName=postgresql-18-pg_textsearch reference: ghcr.io/cloudnative-pg/pg_textsearch:0.4.1-18-trixie @@ -40,12 +40,12 @@ You can install `pg_textsearch` in a specific database by creating or updating a apiVersion: postgresql.cnpg.io/v1 kind: Database metadata: - name: cluster-pg_textsearch-app + name: cluster-pg-textsearch-app spec: name: app owner: app cluster: - name: cluster-pg_textsearch + name: cluster-pg-textsearch extensions: - name: pg_textsearch # renovate: suite=trixie-pgdg depName=postgresql-18-pg_textsearch