version: "3.8"

services:
  timescaledb:
    image: timescale/timescaledb:2.26.4-pg17
    restart: unless-stopped
    expose:
      - 5432
    environment:
      POSTGRES_USER: ${POSTGRES_USER}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
      POSTGRES_DB: ${POSTGRES_DB}
      TIMESCALEDB_TELEMETRY: ${TIMESCALEDB_TELEMETRY}
    volumes:
      - timescaledb-data:/var/lib/postgresql/data
      - ../files/001_create_timescaledb.sql:/docker-entrypoint-initdb.d/001_create_timescaledb.sql:ro
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U \"$${POSTGRES_USER}\" -d \"$${POSTGRES_DB}\""]
      interval: 10s
      timeout: 5s
      retries: 5
      start_period: 20s

volumes:
  timescaledb-data:
