File tree Expand file tree Collapse file tree 4 files changed +143
-0
lines changed
Expand file tree Collapse file tree 4 files changed +143
-0
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ they are maintained by their respective authors, and PostgreSQL Debian Group
2929| Extension | Description | Project URL |
3030| :--- | :--- | :--- |
3131| ** [ pgAudit] ( pgaudit ) ** | PostgreSQL audit extension | [ https://github.com/pgaudit/pgaudit ] ( https://github.com/pgaudit/pgaudit ) |
32+ | ** [ pg-jsonschema] ( pg-jsonschema ) ** | JSON Schema validation for PostgreSQL ` json ` and ` jsonb ` data | [ https://github.com/supabase/pg_jsonschema ] ( https://github.com/supabase/pg_jsonschema ) |
3233| ** [ pgvector] ( pgvector ) ** | Vector similarity search for PostgreSQL | [ https://github.com/pgvector/pgvector ] ( https://github.com/pgvector/pgvector ) |
3334| ** [ PostGIS] ( postgis ) ** | Geospatial database extension for PostgreSQL | [ https://postgis.net/ ] ( https://postgis.net/ ) |
3435
Original file line number Diff line number Diff line change 1+ ARG BASE=ghcr.io/cloudnative-pg/postgresql:18-minimal-trixie
2+ FROM $BASE AS builder
3+
4+ ARG PG_MAJOR
5+ ARG EXT_VERSION
6+ ARG PGRX_VERSION=0.16.1
7+
8+ USER 0
9+
10+ RUN set -eux; \
11+ apt-get update; \
12+ apt-get install -y --no-install-recommends \
13+ ca-certificates \
14+ curl \
15+ git \
16+ build-essential \
17+ libpq-dev \
18+ "postgresql-server-dev-${PG_MAJOR}" \
19+ pkg-config \
20+ cmake \
21+ clang \
22+ libclang-dev; \
23+ rm -rf /var/lib/apt/lists/*
24+
25+ ENV PATH=/root/.cargo/bin:${PATH}
26+
27+ RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --no-modify-path --profile minimal --default-toolchain stable
28+ RUN cargo install cargo-pgrx --version "${PGRX_VERSION}" --locked
29+ RUN cargo pgrx init --pg"${PG_MAJOR}" =/usr/lib/postgresql/"${PG_MAJOR}" /bin/pg_config
30+
31+ WORKDIR /tmp
32+ RUN set -eux; \
33+ curl -fsSL -o pg_jsonschema.tar.gz "https://github.com/supabase/pg_jsonschema/archive/refs/tags/v${EXT_VERSION}.tar.gz" ; \
34+ tar -xzf pg_jsonschema.tar.gz; \
35+ mv "pg_jsonschema-${EXT_VERSION}" pg_jsonschema
36+
37+ WORKDIR /tmp/pg_jsonschema
38+ RUN set -eux; \
39+ cargo pgrx install --release --no-default-features --features "pg${PG_MAJOR}" --pg-config /usr/lib/postgresql/"${PG_MAJOR}" /bin/pg_config
40+
41+ RUN install -D -m 0644 /tmp/pg_jsonschema/LICENSE /licenses/pg_jsonschema/LICENSE
42+
43+ FROM scratch
44+ ARG PG_MAJOR
45+
46+ # Licenses
47+ COPY --from=builder /licenses /licenses/
48+
49+ # Libraries
50+ COPY --from=builder /usr/lib/postgresql/${PG_MAJOR}/lib/pg_jsonschema.so /lib/
51+
52+ # Share
53+ COPY --from=builder /usr/share/postgresql/${PG_MAJOR}/extension/pg_jsonschema* /share/extension/
54+
55+ USER 65532:65532
Original file line number Diff line number Diff line change 1+ # pg_jsonschema
2+
3+ [ pg_jsonschema] ( https://github.com/supabase/pg_jsonschema ) is a PostgreSQL
4+ extension that adds JSON Schema validation for ` json ` and ` jsonb ` data.
5+
6+ This image provides a convenient way to deploy and manage ` pg_jsonschema ` with
7+ [ CloudNativePG] ( https://cloudnative-pg.io/ ) .
8+
9+ ## Usage
10+
11+ ### 1. Add the extension image to your Cluster
12+
13+ Define the ` pg-jsonschema ` extension under the ` postgresql.extensions ` section
14+ of your ` Cluster ` resource. For example:
15+
16+ ``` yaml
17+ apiVersion : postgresql.cnpg.io/v1
18+ kind : Cluster
19+ metadata :
20+ name : cluster-pg-jsonschema
21+ spec :
22+ imageName : ghcr.io/cloudnative-pg/postgresql:18-minimal-trixie
23+ instances : 1
24+
25+ storage :
26+ size : 1Gi
27+
28+ postgresql :
29+ extensions :
30+ - name : pg-jsonschema
31+ image :
32+ # renovate: datasource=github-tags depName=supabase/pg_jsonschema versioning=semver extractVersion=^v(?<version>.*)$
33+ reference : ghcr.io/cloudnative-pg/pg-jsonschema:0.3.4-18-trixie
34+ ` ` `
35+
36+ ### 2. Enable the extension in a database
37+
38+ Create or update a ` Database` resource to install the extension in a specific
39+ database :
40+
41+ ` ` ` yaml
42+ apiVersion: postgresql.cnpg.io/v1
43+ kind: Database
44+ metadata:
45+ name: cluster-pg-jsonschema-app
46+ spec:
47+ name: app
48+ owner: app
49+ cluster:
50+ name: cluster-pg-jsonschema
51+ extensions:
52+ - name: pg_jsonschema
53+ # renovate: datasource=github-tags depName=supabase/pg_jsonschema versioning=semver extractVersion=^v(?<version>.*)$
54+ version: "0.3.4"
55+ ` ` `
56+
57+ # ## 3. Verify installation
58+
59+ Once the database is ready, connect to it with `psql` and run :
60+
61+ ` ` ` sql
62+ \d x
63+ ` ` `
64+
65+ You should see `pg_jsonschema` listed among the installed extensions.
Original file line number Diff line number Diff line change 1+ metadata = {
2+ name = " pg-jsonschema"
3+ sql_name = " pg_jsonschema"
4+ image_name = " pg-jsonschema"
5+ shared_preload_libraries = []
6+ extension_control_path = []
7+ dynamic_library_path = []
8+ ld_library_path = []
9+ auto_update_os_libs = false
10+ required_extensions = []
11+
12+ versions = {
13+ bookworm = {
14+ // renovate: datasource=github-tags depName=supabase/pg_jsonschema versioning=semver extractVersion=^v(?<version>.*)$
15+ " 18" = " 0.3.4"
16+ }
17+ trixie = {
18+ // renovate: datasource=github-tags depName=supabase/pg_jsonschema versioning=semver extractVersion=^v(?<version>.*)$
19+ " 18" = " 0.3.4"
20+ }
21+ }
22+ }
You can’t perform that action at this time.
0 commit comments