diff --git a/compose.yaml b/compose.yaml index c1ae869..c5de703 100644 --- a/compose.yaml +++ b/compose.yaml @@ -4,13 +4,13 @@ services: timescaledb: image: timescale/timescaledb:2.30.1-pg16 environment: - POSTGRES_USER: uptime - POSTGRES_PASSWORD: uptime - POSTGRES_DB: uptime + POSTGRES_PASSWORD: postgres ports: ["5432:5432"] - volumes: [pgdata:/var/lib/postgresql/data] + volumes: + - pgdata:/var/lib/postgresql/data + - ./deploy/dev/postgres-init.sql:/docker-entrypoint-initdb.d/10-uptime.sql:ro healthcheck: - test: ["CMD", "pg_isready", "-U", "uptime"] + test: ["CMD", "pg_isready", "-U", "uptime", "-d", "uptime"] interval: 2s retries: 30 diff --git a/deploy/dev/postgres-init.sql b/deploy/dev/postgres-init.sql new file mode 100644 index 0000000..5060fe0 --- /dev/null +++ b/deploy/dev/postgres-init.sql @@ -0,0 +1,7 @@ +-- Superusers bypass row-level security even with FORCE, so the application +-- must connect as an ordinary role for tenant isolation to be enforced. +CREATE ROLE uptime LOGIN PASSWORD 'uptime'; +CREATE DATABASE uptime OWNER uptime; +\connect uptime +CREATE EXTENSION IF NOT EXISTS timescaledb; +CREATE EXTENSION IF NOT EXISTS citext;