TimescaleDB with DDEV PostgreSQL

A quick guide on enabling TimescaleDB extension in DDEV's PostgreSQL database.

Create .ddev/db-build/Dockerfile.timescaledb

RUN apt-get update \
&& apt-get install -y gnupg lsb-release curl \
&& echo "deb https://packagecloud.io/timescale/timescaledb/debian/ $(lsb_release -cs) main" > /etc/apt/sources.list.d/timescaledb.list \
&& curl -fsSL https://packagecloud.io/timescale/timescaledb/gpgkey | gpg --dearmor -o /etc/apt/trusted.gpg.d/timescaledb.gpg \
&& apt-get update \
&& apt-get install -y timescaledb-2-postgresql-17 \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
RUN mkdir -p /etc/postgresql/conf.d \
&& echo "shared_preload_libraries = 'timescaledb'" > /etc/postgresql/conf.d/timescaledb.conf

Configure post-start hook

hooks:
  post-start:
    - exec: psql -U db -d db -c "CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;"

Note: You must keep the database configuration in your .ddev/config.yaml.
The Dockerfile only extends the base PostgreSQL image; it does not replace it.

Rebuild and restart

ddev delete --omit-snapshot -y
ddev start

Verify installation

ddev exec -s db psql -U db -d db -c "SELECT extname, extversion FROM pg_extension WHERE extname = 'timescaledb';"

You should see the TimescaleDB extension with its version number.

 

 

********************************** ************************* ************************ **************** ****************** *********** ************** ************* ************ *************