diff --git a/.github/workflows/bake.yml b/.github/workflows/bake.yml index efbbfb0..a7a3dfe 100644 --- a/.github/workflows/bake.yml +++ b/.github/workflows/bake.yml @@ -55,6 +55,9 @@ jobs: pg-crash: - 'pg-crash/**' - *shared + pgrepack: + - 'pgrepack/**' + - *shared # Compute a matrix containing the list of all extensions that have been modified - name: Compute matrix diff --git a/README.md b/README.md index 0b9b4ed..f8a51e1 100644 --- a/README.md +++ b/README.md @@ -36,10 +36,10 @@ 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) | +| **[pg_repack](pgrepack)** | re-organize bloated tables and indexes | [github.com/reorg/pg_repack](https://github.com/reorg/pg_repack) | | **[pgvector](pgvector)** | Vector similarity search for PostgreSQL | [github.com/pgvector/pgvector](https://github.com/pgvector/pgvector) | | **[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/pgrepack/Dockerfile b/pgrepack/Dockerfile new file mode 100644 index 0000000..5929408 --- /dev/null +++ b/pgrepack/Dockerfile @@ -0,0 +1,36 @@ +# 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}-repack=${EXT_VERSION}" + +FROM scratch +ARG PG_MAJOR + +# Licenses +COPY --from=builder /usr/share/doc/postgresql-${PG_MAJOR}-repack/copyright /licenses/postgresql-${PG_MAJOR}-repack/ + +# Libraries +COPY --from=builder /usr/lib/postgresql/${PG_MAJOR}/lib/pg_repack* /lib/ + +# Share +COPY --from=builder /usr/share/postgresql/${PG_MAJOR}/extension/pg_repack* /share/extension/ + +USER 65532:65532 diff --git a/pgrepack/README.md b/pgrepack/README.md new file mode 100644 index 0000000..337603e --- /dev/null +++ b/pgrepack/README.md @@ -0,0 +1,111 @@ +# Pg_repack + + + + +The pg_repack PostgreSQL extension provides a binary tool that can perform online operation that can remove bloat from tables and indexes. For more information, see the [official documentation](https://reorg.github.io/pg_repack/). + +## Usage + + + +### 1. Add the pg_repack extension image to your Cluster + +Define the `pg_repack` extension under the `postgresql.extensions` section of +your `Cluster` resource. For example: + +```yaml +apiVersion: postgresql.cnpg.io/v1 +kind: Cluster +metadata: + name: cluster-pg_repack +spec: + imageName: ghcr.io/cloudnative-pg/postgresql:18-minimal-trixie + instances: 1 + + storage: + size: 1Gi + + postgresql: + extensions: + - name: pg_repack + image: + # renovate: suite=trixie-pgdg depName=postgresql-18-pg_repack + reference: ghcr.io/cloudnative-pg/pg_repack:1.0-18-trixie +``` + +### 2. Enable the extension in a database + +You can install `pg_repack` 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_repack-app +spec: + name: app + owner: app + cluster: + name: cluster-pg_repack + extensions: + - name: pg_repack + # renovate: suite=trixie-pgdg depName=postgresql-18-pg_repack extractVersion=^(?\d+\.\d+\.\d+) + version: '1.0' +``` + + + +### 3. Verify installation + +Once the database is ready, connect to it with `psql` and run: + +```sql +\dx +``` + +You should see `pg_repack` 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_repack` 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/pgrepack/metadata.hcl b/pgrepack/metadata.hcl new file mode 100644 index 0000000..b3cdc08 --- /dev/null +++ b/pgrepack/metadata.hcl @@ -0,0 +1,41 @@ +# SPDX-FileCopyrightText: Copyright © contributors to CloudNativePG, established as CloudNativePG a Series of LF Projects, LLC. +# SPDX-License-Identifier: Apache-2.0 +metadata = { + name = "pgrepack" + sql_name = "pg_repack" + image_name = "pgrepack" + licenses = ["BSD-3-Clause"] + shared_preload_libraries = ["pg_repack"] + extension_control_path = [] + dynamic_library_path = [] + ld_library_path = [] + bin_path = [] + auto_update_os_libs = false + required_extensions = [] + create_extension = true + + # TODO: Add these missing variables in the template + env = {} + postgresql_parameters = {} + + versions = { + trixie = { + "18" = { + // renovate: suite=trixie-pgdg depName=postgresql-18-pg_repack + package = "1.5.3-1.pgdg13+1" + // Examples: \d+\.\d+ for major.minor (e.g., "18.0"), \d+\.\d+\.\d+ for major.minor.patch (e.g., "0.8.2") + // renovate: suite=trixie-pgdg depName=postgresql-18-pg_repack extractVersion=^(?\d+\.\d+\.\d+) + sql = "1.5.3" + } + } + bookworm = { + "18" = { + // renovate: suite=bookworm-pgdg depName=postgresql-18-pg_repack + package = "1.5.3-1.pgdg12+1" + // Examples: \d+\.\d+ for major.minor (e.g., "18.0"), \d+\.\d+\.\d+ for major.minor.patch (e.g., "0.8.2") + // renovate: suite=bookworm-pgdg depName=postgresql-18-pg_repack extractVersion=^(?\d+\.\d+\.\d+) + sql = "1.5.3" + } + } + } +}