diff --git a/CODEOWNERS b/CODEOWNERS index f4dd1e7..c82178a 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -3,3 +3,4 @@ # https://docs.github.com/en/free-pro-team@latest/github/creating-cloning-and-archiving-repositories/about-code-owners * @cloudnative-pg/maintainers @NiccoloFei +/vchord/ @xieydd diff --git a/README.md b/README.md index fc0759f..35edb4b 100644 --- a/README.md +++ b/README.md @@ -37,9 +37,9 @@ they are maintained by their respective authors, and PostgreSQL Debian Group | **[pgAudit](pgaudit)** | PostgreSQL audit extension | [github.com/pgaudit/pgaudit](https://github.com/pgaudit/pgaudit) | | **[pg_crash](pg-crash)** | **Disruptive** fault injection and chaos engineering extension | [github.com/cybertec-postgresql/pg_crash](https://github.com/cybertec-postgresql/pg_crash) | | **[pgvector](pgvector)** | Vector similarity search for PostgreSQL | [github.com/pgvector/pgvector](https://github.com/pgvector/pgvector) | +| **[VectorChord](vchord)** | Scalable and disk-efficient vector search for PostgreSQL | [vectorchord.ai](https://vectorchord.ai) | | **[PostGIS](postgis)** | Geospatial database extension for PostgreSQL | [postgis.net/](https://postgis.net/) | - Extensions are provided only for the OS versions already built by the [`cloudnative-pg/postgres-containers`](https://github.com/cloudnative-pg/postgres-containers) project, specifically Debian `stable` and `oldstable`. diff --git a/renovate.json b/renovate.json index 57dcf1b..e7b122c 100644 --- a/renovate.json +++ b/renovate.json @@ -22,6 +22,16 @@ "registryUrlTemplate": "https://download.postgresql.org/pub/repos/apt?suite={{#if suite}}{{suite}}{{else}}stable{{/if}}&components=main&binaryArch=amd64", "datasourceTemplate": "deb" }, + { + "description": "updates github release versions in vchord metadata.hcl", + "customType": "regex", + "managerFilePatterns": [ + "vchord/metadata.hcl" + ], + "matchStrings": [ + "\\/\\/\\s*renovate:\\s*datasource=(?[a-z-.]+?)\\s+depName=(?[^\\s]+?)(?:\\s+versioning=(?[^\\s]+?))?(?:\\s+extractVersion=(?[^\\s]+?))?\\s*\"[A-Za-z0-9_-]+\"\\s*=\\s*\"(?[^\"]+)\"" + ] + }, { "description": "updates the container image versions in the README.md files", "customType": "regex", diff --git a/vchord/Dockerfile b/vchord/Dockerfile new file mode 100644 index 0000000..c623bf2 --- /dev/null +++ b/vchord/Dockerfile @@ -0,0 +1,36 @@ +ARG BASE=ghcr.io/cloudnative-pg/postgresql:18-minimal-trixie +FROM $BASE AS builder + +ARG PG_MAJOR +ARG EXT_VERSION + +USER 0 + +RUN set -eux; \ + ext_tag="${EXT_VERSION%%-*}"; \ + arch="$(dpkg --print-architecture)"; \ + package_name="postgresql-${PG_MAJOR}-vchord_${ext_tag}-1_${arch}.deb"; \ + apt-get update && \ + apt-get install -y --no-install-recommends wget ca-certificates && \ + wget "https://github.com/tensorchord/VectorChord/releases/download/${ext_tag}/${package_name}" -P /tmp && \ + dpkg-deb -x "/tmp/${package_name}" /sysroot && \ + install -Dm644 /dev/null "/sysroot/usr/share/doc/postgresql-${PG_MAJOR}-vchord/copyright" && \ + wget "https://raw.githubusercontent.com/tensorchord/VectorChord/${ext_tag}/LICENSE" \ + -O "/sysroot/usr/share/doc/postgresql-${PG_MAJOR}-vchord/copyright" && \ + apt-get remove -y wget ca-certificates && \ + apt-get purge -y --auto-remove && \ + rm -rf /tmp/* /var/lib/apt/lists/* + +FROM scratch +ARG PG_MAJOR + +# Licenses +COPY --from=builder /sysroot/usr/share/doc/postgresql-${PG_MAJOR}-vchord/copyright /licenses/postgresql-${PG_MAJOR}-vchord/ + +# Libraries +COPY --from=builder /sysroot/usr/lib/postgresql/${PG_MAJOR}/lib/vchord* /lib/ + +# Share +COPY --from=builder /sysroot/usr/share/postgresql/${PG_MAJOR}/extension/vchord* /share/extension/ + +USER 65532:65532 diff --git a/vchord/README.md b/vchord/README.md new file mode 100644 index 0000000..d65386e --- /dev/null +++ b/vchord/README.md @@ -0,0 +1,68 @@ +# VectorChord + +[VectorChord](https://github.com/tensorchord/VectorChord) is an open-source extension for high-performance and disk-efficient vector similarity search in PostgreSQL. + +This image provides a convenient way to deploy and manage `vchord` with [CloudNativePG](https://cloudnative-pg.io/). + +## Usage + +### 1. Add pgvector and VectorChord extension images to your Cluster + +`vchord` depends on `pgvector`, so both extensions must be configured in your `Cluster` resource: + +```yaml +apiVersion: postgresql.cnpg.io/v1 +kind: Cluster +metadata: + name: cluster-vchord +spec: + imageName: ghcr.io/cloudnative-pg/postgresql:18-minimal-trixie + instances: 1 + + storage: + size: 1Gi + + postgresql: + shared_preload_libraries: + - vchord + extensions: + - name: pgvector + image: + # renovate: suite=trixie-pgdg depName=postgresql-18-pgvector + reference: ghcr.io/cloudnative-pg/pgvector:0.8.1-18-trixie + - name: vchord + image: + reference: ghcr.io/cloudnative-pg/vchord:1.1.1-18-trixie +``` + +### 2. Enable the extensions in a database + +Create or update a `Database` resource and ensure `vector` is available before `vchord`: + +```yaml +apiVersion: postgresql.cnpg.io/v1 +kind: Database +metadata: + name: cluster-vchord-app +spec: + name: app + owner: app + cluster: + name: cluster-vchord + extensions: + - name: vector + # renovate: suite=trixie-pgdg depName=postgresql-18-pgvector + version: '0.8.1' + - name: vchord + version: '1.1.1' +``` + +### 3. Verify installation + +Once the database is ready, connect to it with `psql` and run: + +```sql +\dx +``` + +You should see both `vector` and `vchord` listed among installed extensions. diff --git a/vchord/metadata.hcl b/vchord/metadata.hcl new file mode 100644 index 0000000..318a97f --- /dev/null +++ b/vchord/metadata.hcl @@ -0,0 +1,24 @@ +metadata = { + name = "vchord" + sql_name = "vchord" + image_name = "vchord" + licenses = ["AGPL-3.0-only OR Elastic-2.0"] + shared_preload_libraries = ["vchord"] + extension_control_path = [] + dynamic_library_path = [] + ld_library_path = [] + auto_update_os_libs = false + required_extensions = ["pgvector"] + create_extension = true + + versions = { + bookworm = { + // renovate: datasource=github-releases depName=tensorchord/VectorChord versioning=semver extractVersion=^v(?.*)$ + "18" = "1.1.1" + } + trixie = { + // renovate: datasource=github-releases depName=tensorchord/VectorChord versioning=semver extractVersion=^v(?.*)$ + "18" = "1.1.1" + } + } +}