From 5a330d1cbc54df77ecb7b5248e1bdd330ba6ffd9 Mon Sep 17 00:00:00 2001 From: Enno Richter <2536303+elohmeier@users.noreply.github.com> Date: Thu, 16 Apr 2026 11:16:47 +0200 Subject: [PATCH] feat: add `pg-jsonschema` container image Add the pg_jsonschema extension image using Supabase release Debian packages for PostgreSQL 18 on bookworm and trixie. Closes #117 Signed-off-by: Enno Richter <2536303+elohmeier@users.noreply.github.com> --- CODEOWNERS | 3 ++ README.md | 2 +- pg-jsonschema/Dockerfile | 41 +++++++++++++++++++ pg-jsonschema/README.md | 83 ++++++++++++++++++++++++++++++++++++++ pg-jsonschema/metadata.hcl | 35 ++++++++++++++++ 5 files changed, 163 insertions(+), 1 deletion(-) create mode 100644 pg-jsonschema/Dockerfile create mode 100644 pg-jsonschema/README.md create mode 100644 pg-jsonschema/metadata.hcl diff --git a/CODEOWNERS b/CODEOWNERS index 82a1a8a4..ac67cb32 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -9,3 +9,6 @@ # wal2json /wal2json/ @cloudnative-pg/maintainers @NiccoloFei @solidDoWant + +# pg_jsonschema +/pg-jsonschema/ @elohmeier @cloudnative-pg/maintainers @NiccoloFei diff --git a/README.md b/README.md index 7be75e4b..2ce20a74 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,7 @@ from a trusted, auditable repository | :--- | :--- | :--- | :--- | | **[pgAudit](pgaudit)** | PostgreSQL audit extension | [github.com/pgaudit/pgaudit](https://github.com/pgaudit/pgaudit) | CNPG maintainers | | **[pg_crash](pg-crash)** | **Disruptive** fault injection and chaos engineering extension | [github.com/cybertec-postgresql/pg_crash](https://github.com/cybertec-postgresql/pg_crash) | CNPG maintainers | +| **[pg_jsonschema](pg-jsonschema)** | JSON Schema validation for PostgreSQL `json` and `jsonb` data | [github.com/supabase/pg_jsonschema](https://github.com/supabase/pg_jsonschema) | @elohmeier | | **[pgvector](pgvector)** | Vector similarity search for PostgreSQL | [github.com/pgvector/pgvector](https://github.com/pgvector/pgvector) | CNPG maintainers | | **[PostGIS](postgis)** | Geospatial database extension for PostgreSQL | [postgis.net/](https://postgis.net/) | CNPG maintainers | | **[TimescaleDB Apache-2 Edition](timescaledb-oss)** | Time-series database for PostgreSQL (open source version) | [github.com/timescale/timescaledb/](https://github.com/timescale/timescaledb/) | @shusaan | @@ -208,4 +209,3 @@ list of compatible extension images for PostgreSQL 18+ versions. project](https://github.com/cloudnative-pg/artifacts/tree/main/image-catalogs-extensions). - **Naming Convention:** These are based on the `minimal` catalog and use the `catalog-minimal` prefix (e.g., `catalog-minimal-trixie.yaml`). - diff --git a/pg-jsonschema/Dockerfile b/pg-jsonschema/Dockerfile new file mode 100644 index 00000000..dc3a2a45 --- /dev/null +++ b/pg-jsonschema/Dockerfile @@ -0,0 +1,41 @@ +ARG BASE=ghcr.io/cloudnative-pg/postgresql:18-minimal-trixie +FROM $BASE AS builder + +ARG PG_MAJOR +ARG EXT_VERSION +ARG TARGETARCH + +USER 0 + +RUN set -eux; \ + apt-get update; \ + apt-get install -y --no-install-recommends ca-certificates curl; \ + rm -rf /var/lib/apt/lists/* + +RUN set -eux; \ + case "${TARGETARCH}" in \ + amd64) arch="amd64" ;; \ + arm64) arch="arm64" ;; \ + *) echo "unsupported architecture: ${TARGETARCH}" >&2; exit 1 ;; \ + esac; \ + curl -fsSL -o /tmp/pg_jsonschema.deb \ + "https://github.com/supabase/pg_jsonschema/releases/download/v${EXT_VERSION}/pg_jsonschema-v${EXT_VERSION}-pg${PG_MAJOR}-${arch}-linux-gnu.deb"; \ + dpkg -i /tmp/pg_jsonschema.deb; \ + rm /tmp/pg_jsonschema.deb; \ + curl -fsSL -o /licenses/pg_jsonschema/LICENSE \ + --create-dirs \ + "https://raw.githubusercontent.com/supabase/pg_jsonschema/v${EXT_VERSION}/LICENSE" + +FROM scratch +ARG PG_MAJOR + +# Licenses +COPY --from=builder /licenses /licenses/ + +# Libraries +COPY --from=builder /usr/lib/postgresql/${PG_MAJOR}/lib/pg_jsonschema.so /lib/ + +# Share +COPY --from=builder /usr/share/postgresql/${PG_MAJOR}/extension/pg_jsonschema* /share/extension/ + +USER 65532:65532 diff --git a/pg-jsonschema/README.md b/pg-jsonschema/README.md new file mode 100644 index 00000000..b2e336bf --- /dev/null +++ b/pg-jsonschema/README.md @@ -0,0 +1,83 @@ +# pg_jsonschema + +[pg_jsonschema](https://github.com/supabase/pg_jsonschema) is a PostgreSQL +extension that adds JSON Schema validation for `json` and `jsonb` data. + +This image provides a convenient way to deploy and manage `pg_jsonschema` with +[CloudNativePG](https://cloudnative-pg.io/). + +The image installs the official `.deb` packages published in Supabase's +`pg_jsonschema` GitHub releases. + +## Usage + +### 1. Add the extension image to your Cluster + +Define the `pg-jsonschema` extension under the `postgresql.extensions` section +of your `Cluster` resource. For example: + +```yaml +apiVersion: postgresql.cnpg.io/v1 +kind: Cluster +metadata: + name: cluster-pg-jsonschema +spec: + imageName: ghcr.io/cloudnative-pg/postgresql:18-minimal-trixie + instances: 1 + + storage: + size: 1Gi + + postgresql: + extensions: + - name: pg-jsonschema + image: + # renovate: datasource=github-tags depName=supabase/pg_jsonschema versioning=semver extractVersion=^v(?.*)$ + reference: ghcr.io/cloudnative-pg/pg-jsonschema:0.3.4-18-trixie +``` + +### 2. Enable the extension in a database + +Create or update a `Database` resource to install the extension in a specific +database: + +```yaml +apiVersion: postgresql.cnpg.io/v1 +kind: Database +metadata: + name: cluster-pg-jsonschema-app +spec: + name: app + owner: app + cluster: + name: cluster-pg-jsonschema + extensions: + - name: pg_jsonschema + # renovate: datasource=github-tags depName=supabase/pg_jsonschema versioning=semver extractVersion=^v(?.*)$ + version: "0.3.4" +``` + +### 3. Verify installation + +Once the database is ready, connect to it with `psql` and run: + +```sql +\dx +``` + +You should see `pg_jsonschema` listed among the installed extensions. + +## Contributors + +This extension is maintained by: + +- @elohmeier + +## Licenses and Copyright + +The `pg_jsonschema` extension is licensed under Apache-2.0. License information +is bundled in the image under: + +```text +/licenses/ +``` diff --git a/pg-jsonschema/metadata.hcl b/pg-jsonschema/metadata.hcl new file mode 100644 index 00000000..dd837ca8 --- /dev/null +++ b/pg-jsonschema/metadata.hcl @@ -0,0 +1,35 @@ +metadata = { + name = "pg-jsonschema" + sql_name = "pg_jsonschema" + image_name = "pg-jsonschema" + licenses = ["Apache-2.0"] + shared_preload_libraries = [] + postgresql_parameters = {} + extension_control_path = [] + dynamic_library_path = [] + ld_library_path = [] + bin_path = [] + env = {} + auto_update_os_libs = false + required_extensions = [] + create_extension = true + + versions = { + bookworm = { + "18" = { + // renovate: datasource=github-tags depName=supabase/pg_jsonschema versioning=semver extractVersion=^v(?.*)$ + package = "0.3.4" + // renovate: datasource=github-tags depName=supabase/pg_jsonschema versioning=semver extractVersion=^v(?.*)$ + sql = "0.3.4" + } + } + trixie = { + "18" = { + // renovate: datasource=github-tags depName=supabase/pg_jsonschema versioning=semver extractVersion=^v(?.*)$ + package = "0.3.4" + // renovate: datasource=github-tags depName=supabase/pg_jsonschema versioning=semver extractVersion=^v(?.*)$ + sql = "0.3.4" + } + } + } +}