# Self-host TimescaleDB

> PostgreSQL with the TimescaleDB extension for time series data, with a persistent volume and a generated password. The core is Apache-2.0 and some features fall under the Timescale License. It is not published on the host, so reach it from other services in this project at timescaledb:5432.

- Page: https://levelrail.com/templates/timescaledb/
- JSON: https://levelrail.com/templates/timescaledb.json
- Category: Database Tools
- Licence: LicenseRef-Timescale (Source available)
- Source: https://github.com/timescale/timescaledb
- Upstream docs: https://docs.timescale.com/

## Requirements
- Memory: about 512 MiB
- amd64: unknown, arm64: unknown
- Needs configuration before start: no
- Pinned image tag: 2.30.2-pg17

## Services

| Service | Image | Tag | Ports | Volumes |
| --- | --- | --- | --- | --- |
| timescaledb | timescale/timescaledb | 2.30.2-pg17 | 5432 | tsdata -> /var/lib/postgresql/data |

## Environment

| Service | Variable | Kind |
| --- | --- | --- |
| timescaledb | POSTGRES_DB | preset |
| timescaledb | POSTGRES_PASSWORD | generated |
| timescaledb | POSTGRES_USER | preset |

## Deploy

### CLI

```bash
levelrail-cli templates install timescaledb --name my-timescaledb
```

Add --domain SERVICE=HOST to serve a service on your own domain, for example --domain timescaledb=app.example.com.

### API

```bash
curl -X POST -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
  https://levelrail.example.com/api/v1/service-templates/timescaledb/install \
  -d '{
    "name": "my-timescaledb"
  }'
```

Create a token in the dashboard first. Name, env and domains are the request fields.

## First run
1. Read the generated password from the app secrets, connect from a service in the same project, The extension is already created in the default database. Run CREATE EXTENSION IF NOT EXISTS timescaledb in any other database you add.

## Questions

### Can I deploy TimescaleDB on Dokploy or Dokku?

The services and pinned images on this page can be run on any Docker host. The public Dokploy templates list has an entry with the id timescaledb for this app, so check that entry as well. Dokku deploys container images with its own commands, so the pinned image timescale/timescaledb:2.30.2-pg17 is what you deploy there.

Self-host TimescaleDB, TimescaleDB docker compose file, deploy TimescaleDB on a VPS: this page lists the pinned image, ports, volumes and the commands for each.
