Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/bake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ on:
- postgis
- pgaudit
- pg-crash
- first-last-agg

defaults:
run:
Expand Down Expand Up @@ -55,6 +56,9 @@ jobs:
pg-crash:
- 'pg-crash/**'
- *shared
first-last-agg:
- 'first-last-agg/**'
- *shared

# Compute a matrix containing the list of all extensions that have been modified
- name: Compute matrix
Expand Down
25 changes: 25 additions & 0 deletions first-last-agg/Dockerfile
Original file line number Diff line number Diff line change
@@ -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}-first-last-agg=${EXT_VERSION}"

FROM scratch
ARG PG_MAJOR

# Licenses
COPY --from=builder /usr/share/doc/postgresql-${PG_MAJOR}-first-last-agg/copyright /licenses/postgresql-${PG_MAJOR}-first-last-agg/

# Libraries
COPY --from=builder /usr/lib/postgresql/${PG_MAJOR}/lib/first_last_agg* /lib/
COPY --from=builder /usr/lib/postgresql/${PG_MAJOR}/lib/bitcode/ /lib/bitcode/

# Share
COPY --from=builder /usr/share/postgresql/${PG_MAJOR}/extension/first_last_agg* /share/extension/

USER 65532:65532
67 changes: 67 additions & 0 deletions first-last-agg/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# First-Last-Agg

[First-Last-Agg](https://github.com/wulczer/first_last_agg) is a simple
extension providing two aggregate functions, last and first aggregate
functions, operating on any element type and returning the last or the first
value of the group.

This image provides a convenient way to deploy and manage `first_last_agg` with
[CloudNativePG](https://cloudnative-pg.io/).

## Usage

### 1. Add the first_last_agg extension image to your Cluster

Define the `first_last_agg` extension under the `postgresql.extensions` section of
your `Cluster` resource. For example:

```yaml
apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
name: cluster-first-last-agg
spec:
imageName: ghcr.io/cloudnative-pg/postgresql:18-minimal-trixie
instances: 1

storage:
size: 1Gi

postgresql:
extensions:
- name: first_last_agg
image:
# renovate: suite=trixie-pgdg depName=postgresql-18-first-last-agg
reference: ghcr.io/cloudnative-pg/first-last-agg:0.8.2-18-trixie
```

### 2. Enable the extension in a database

You can install `first_last_agg` 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-first-last-agg-app
spec:
name: app
owner: app
cluster:
name: cluster-first-last-agg
extensions:
- name: first_last_agg
# renovate: suite=trixie-pgdg depName=postgresql-18-first-last-agg extractVersion=^(?<version>\d+\.\d+\.\d+)
version: '0.8.2'
```

### 3. Verify installation

Once the database is ready, connect to it with `psql` and run:

```sql
\dx
```

You should see `first_last_agg` listed among the installed extensions.
35 changes: 35 additions & 0 deletions first-last-agg/metadata.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
metadata = {
name = "first-last-agg"
sql_name = "first_last_agg"
image_name = "first-last-agg"
licenses = ["PostgreSQL"]
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: suite=bookworm-pgdg depName=postgresql-18-first-last-agg
package = "0.1.4-4-gd63ea3b-9.pgdg12+1"
// renovate: suite=bookworm-pgdg depName=postgresql-18-first-last-agg extractVersion=^(?<version>\d+\.\d+\.\d+)
sql = "0.1.4"
}
}
trixie = {
"18" = {
// renovate: suite=trixie-pgdg depName=postgresql-18-first-last-agg
package = "0.1.4-4-gd63ea3b-9.pgdg13+1"
// renovate: suite=trixie-pgdg depName=postgresql-18-first-last-agg extractVersion=^(?<version>\d+\.\d+\.\d+)
sql = "0.1.4"
}
}
}
}