diff --git a/pg_partman/Dockerfile b/pg_partman/Dockerfile new file mode 100644 index 0000000..eb08ca3 --- /dev/null +++ b/pg_partman/Dockerfile @@ -0,0 +1,25 @@ +ARG BASE=ghcr.io/cloudnative-pg/postgresql:18-minimal-trixie +FROM $BASE AS builder + +ARG PG_MAJOR +ARG EXT_VERSION + +USER 0 + +RUN apt-get update && \ + apt-get install -y --no-install-recommends "postgresql-${PG_MAJOR}-partman=${EXT_VERSION}" + +FROM scratch +ARG PG_MAJOR + +# Licenses +COPY --from=builder /usr/share/doc/postgresql-${PG_MAJOR}-partman/copyright /licenses/postgresql-${PG_MAJOR}-partman/ + +# Libraries +COPY --from=builder /usr/lib/postgresql/${PG_MAJOR}/lib/pg_partman* /lib/ +COPY --from=builder /usr/lib/postgresql/${PG_MAJOR}/lib/bitcode/ /lib/bitcode/ + +# Share +COPY --from=builder /usr/share/postgresql/${PG_MAJOR}/extension/pg_partman* /share/extension/ + +USER 65532:65532 diff --git a/pg_partman/README.md b/pg_partman/README.md new file mode 100644 index 0000000..1bcff91 --- /dev/null +++ b/pg_partman/README.md @@ -0,0 +1,62 @@ +# pg\_partman + +[pg\_partman](https://github.com/pgpartman/pg_partman) is an open-source extension +that enables **automatic partition management** in PostgreSQL. + +This image provides a convenient way to deploy and manage `pg_partman` with +[CloudNativePG](https://cloudnative-pg.io/). + +## Usage + +### 1. Add the pg\_partman extension image to your Cluster + +Define the `pg_partman` extension under the `postgresql.extensions` section of +your `Cluster` resource. For example: + +```yaml +apiVersion: postgresql.cnpg.io/v1 +kind: Cluster +metadata: + name: cluster-pgvector +spec: + imageName: ghcr.io/cloudnative-pg/postgresql:18-minimal-trixie + instances: 1 + + storage: + size: 1Gi + + postgresql: + extensions: + - name: pg_partman + image: + reference: ghcr.io/cloudnative-pg/pg_partman:5.3.1-2-trixie +``` + +### 2. Enable the extension in a database + +You can install `pg_partman` 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_partman-app +spec: + name: app + owner: app + cluster: + name: cluster-pg_partman + extensions: + - name: pg_partman +``` + +### 3. Verify installation + +Once the database is ready, connect to it with `psql` and run: + +```sql +\dx +``` + +You should see `pg_partman` listed among the installed extensions. diff --git a/pg_partman/metadata.json b/pg_partman/metadata.json new file mode 100644 index 0000000..09727b3 --- /dev/null +++ b/pg_partman/metadata.json @@ -0,0 +1,18 @@ +{ + "metadata": { + "name": "pg_partman", + "sql_name": "pg_partman", + "shared_preload_libraries": ["pg_partman_bgw"], + "extension_control_path": [], + "dynamic_library_path": [], + "ld_library_path": [], + "versions": { + "bookworm": { + "18": "5.3.1-2.pgdg13+1" + }, + "trixie": { + "18": "5.3.1-2.pgdg13+1" + } + } + } +}