Skip to content

Commit 5a5ea0f

Browse files
shusaangbartolini
authored andcommitted
feat: added timescaledb
Signed-off-by: Husn E Rabbi <shussan@gmail.com>
1 parent 2716417 commit 5a5ea0f

File tree

5 files changed

+127
-0
lines changed

5 files changed

+127
-0
lines changed

.github/workflows/bake.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ jobs:
4949
postgis:
5050
- 'postgis/**'
5151
- *shared
52+
timescaledb:
53+
- 'timescaledb/**'
54+
- *shared
5255
pgaudit:
5356
- 'pgaudit/**'
5457
- *shared

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ they are maintained by their respective authors, and PostgreSQL Debian Group
3131
| **[pgAudit](pgaudit)** | PostgreSQL audit extension | [https://github.com/pgaudit/pgaudit](https://github.com/pgaudit/pgaudit) |
3232
| **[pgvector](pgvector)** | Vector similarity search for PostgreSQL | [https://github.com/pgvector/pgvector](https://github.com/pgvector/pgvector) |
3333
| **[PostGIS](postgis)** | Geospatial database extension for PostgreSQL | [https://postgis.net/](https://postgis.net/) |
34+
| **[Timescaledb](timescaledb)** | Time-series database for PostgreSQL | [https://github.com/timescale/timescaledb/](https://github.com/timescale/timescaledb/) |
3435

3536

3637
Extensions are provided only for the OS versions already built by the

timescaledb/Dockerfile

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
2+
ARG BASE=ghcr.io/cloudnative-pg/postgresql:18-minimal-trixie
3+
FROM $BASE AS builder
4+
5+
ARG PG_MAJOR
6+
ARG EXT_VERSION
7+
8+
USER 0
9+
RUN set -eux; \
10+
apt-get update; \
11+
apt-get install -y --no-install-recommends gnupg postgresql-common apt-transport-https lsb-release wget ca-certificates; \
12+
# Add TimescaleDB package repository
13+
echo "deb https://packagecloud.io/timescale/timescaledb/debian/ $(lsb_release -c -s) main" > /etc/apt/sources.list.d/timescaledb.list; \
14+
wget --quiet -O - https://packagecloud.io/timescale/timescaledb/gpgkey | gpg --dearmor -o /etc/apt/trusted.gpg.d/timescaledb.gpg; \
15+
apt-get update; \
16+
apt-get install -y --no-install-recommends \
17+
timescaledb-2-oss-postgresql-${PG_MAJOR}=${EXT_VERSION}*
18+
19+
######################################################################
20+
# Final SCRATCH image
21+
######################################################################
22+
FROM scratch
23+
ARG PG_MAJOR
24+
25+
# Licenses
26+
COPY --from=builder /usr/share/doc/timescaledb-2-oss-postgresql-${PG_MAJOR}/copyright /licenses/timescaledb/
27+
28+
# Libraries — .so and bitcode for TimescaleDB
29+
COPY --from=builder /usr/lib/postgresql/${PG_MAJOR}/lib/timescaledb* /lib/
30+
COPY --from=builder /usr/lib/postgresql/${PG_MAJOR}/lib/timescaledb-2* /lib/
31+
32+
# Extension SQL + control files
33+
COPY --from=builder /usr/share/postgresql/${PG_MAJOR}/extension/timescaledb* /share/extension/
34+
35+
USER 65532:65532

timescaledb/README.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# TimescaleDB (Apache 2.0 Edition) with CloudNativePG
2+
3+
[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.
4+
5+
**Note**: This image contains only the Apache 2.0 licensed components of TimescaleDB to ensure CNCF licensing compliance. Advanced features requiring the Timescale License (TSL) are not included.
6+
7+
This image provides a convenient way to deploy and manage the open-source core of `TimescaleDB` with
8+
[CloudNativePG](https://cloudnative-pg.io/).
9+
10+
## Usage
11+
12+
### 1. Add the timescaledb extension image to your Cluster
13+
14+
Define the `timescaledb` extension under the `postgresql.extensions` section of
15+
your `Cluster` resource. For example:
16+
17+
```yaml
18+
apiVersion: postgresql.cnpg.io/v1
19+
kind: Cluster
20+
metadata:
21+
name: cluster-timescaledb
22+
spec:
23+
imageName: ghcr.io/cloudnative-pg/postgresql:18-minimal-trixie
24+
instances: 1
25+
26+
storage:
27+
size: 1Gi
28+
29+
postgresql:
30+
shared_preload_libraries:
31+
- "timescaledb"
32+
parameters:
33+
timescaledb.telemetry_level: 'off'
34+
max_locks_per_transaction: '128'
35+
36+
extensions:
37+
- name: timescaledb
38+
image:
39+
reference: ghcr.io/cloudnative-pg/timescaledb:2.23.1-18-trixie
40+
```
41+
42+
### 2. Enable the extension in a database
43+
44+
You can install `timescaledb` in a specific database by creating or updating a
45+
`Database` resource. For example, to enable it in the `app` database:
46+
47+
```yaml
48+
apiVersion: postgresql.cnpg.io/v1
49+
kind: Database
50+
metadata:
51+
name: cluster-timescaledb-app
52+
spec:
53+
name: app
54+
owner: app
55+
cluster:
56+
name: cluster-timescaledb
57+
extensions:
58+
- name: timescaledb
59+
```
60+
61+
### 3. Verify installation
62+
63+
Once the database is ready, connect to it with `psql` and run:
64+
65+
```sql
66+
\dx
67+
```
68+
69+
You should see `timescaledb` listed among the installed extensions.

timescaledb/metadata.hcl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
metadata = {
2+
name = "timescaledb"
3+
sql_name = "timescaledb"
4+
image_name = "timescaledb"
5+
shared_preload_libraries = ["timescaledb"]
6+
extension_control_path = []
7+
dynamic_library_path = []
8+
ld_library_path = []
9+
versions = {
10+
bookworm = {
11+
// renovate: datasource=postgresql depName=timescaledb-2-oss-postgresql-18 versioning=deb
12+
"18" = "2.24.0~debian12-1801"
13+
}
14+
trixie = {
15+
// renovate: datasource=postgresql depName=timescaledb-2-oss-postgresql-18 versioning=deb
16+
"18" = "2.24.0~debian13-1801"
17+
}
18+
}
19+
}

0 commit comments

Comments
 (0)