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
3 changes: 3 additions & 0 deletions .github/workflows/bake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ on:
options:
- pgvector
- postgis
- timescaledb
- pgaudit

defaults:
Expand Down Expand Up @@ -48,6 +49,8 @@ jobs:
- *shared
postgis:
- 'postgis/**'
timescaledb:
- 'timescaledb/**'
- *shared
pgaudit:
- 'pgaudit/**'
Expand Down
36 changes: 36 additions & 0 deletions timescaledb/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@

ARG BASE=ghcr.io/cloudnative-pg/postgresql:18-minimal-trixie
FROM $BASE AS builder

ARG PG_MAJOR
ARG EXT_VERSION

USER 0
RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends gnupg postgresql-common apt-transport-https lsb-release wget ca-certificates; \
# Add TimescaleDB package repository
echo "deb https://packagecloud.io/timescale/timescaledb/debian/ $(lsb_release -c -s) main" > /etc/apt/sources.list.d/timescaledb.list; \
wget --quiet -O - https://packagecloud.io/timescale/timescaledb/gpgkey | gpg --dearmor -o /etc/apt/trusted.gpg.d/timescaledb.gpg; \
apt-get update; \
apt-get install -y --no-install-recommends \
timescaledb-2-postgresql-${PG_MAJOR}=${EXT_VERSION}* \
timescaledb-2-loader-postgresql-${PG_MAJOR}=${EXT_VERSION}*

######################################################################
# Final SCRATCH image
######################################################################
FROM scratch
ARG PG_MAJOR

# Licenses
COPY --from=builder /usr/share/doc/timescaledb-2-postgresql-${PG_MAJOR}/copyright /licenses/timescaledb/

# Libraries — .so and bitcode for TimescaleDB
COPY --from=builder /usr/lib/postgresql/${PG_MAJOR}/lib/timescaledb* /lib/
COPY --from=builder /usr/lib/postgresql/${PG_MAJOR}/lib/timescaledb-2* /lib/

# Extension SQL + control files
COPY --from=builder /usr/share/postgresql/${PG_MAJOR}/extension/timescaledb* /share/extension/

USER 65532:65532
67 changes: 67 additions & 0 deletions timescaledb/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# TimescaleDB with CloudNativePG

[TimescaleDB](https://github.com/timescale/timescaledb) is the leading open-source time-series database, built on PostgreSQL. It enables fast analytics, efficient storage, and powerful querying for time-series workloads.

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

## Usage

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

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

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

storage:
size: 1Gi

postgresql:
shared_preload_libraries:
- "timescaledb"
parameters:
timescaledb.telemetry_level: 'off'
max_locks_per_transaction: '128'

extensions:
- name: timescaledb
image:
reference: ghcr.io/cloudnative-pg/timescaledb:2.23.1-18-trixie
```

### 2. Enable the extension in a database

You can install `timescaledb` 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-timescaledb-app
spec:
name: app
owner: app
cluster:
name: cluster-timescaledb
extensions:
- name: timescaledb
```

### 3. Verify installation

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

```sql
\dx
```

You should see `timescaledb` listed among the installed extensions.
19 changes: 19 additions & 0 deletions timescaledb/metadata.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
metadata = {
name = "timescaledb"
sql_name = "timescaledb"
image_name = "timescaledb"
shared_preload_libraries = ["timescaledb"]
extension_control_path = []
dynamic_library_path = []
ld_library_path = []
versions = {
bookworm = {
// renovate: datasource=postgresql depName=timescaledb-2-postgresql-18 versioning=deb
"18" = "2.23.1~debian12-1800"
}
trixie = {
// renovate: datasource=postgresql depName=timescaledb-2-postgresql-18 versioning=deb
"18" = "2.23.1~debian13-1800"
}
}
}