services:
  # PostgreSQL Database
  postgres:
    image: postgres:16-alpine
    container_name: nodels-postgres
    environment:
      POSTGRES_USER: nodels
      POSTGRES_PASSWORD: nodels_dev
      POSTGRES_DB: nodels
    ports:
      - "5432:5432"
    volumes:
      - postgres_data:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U nodels"]
      interval: 10s
      timeout: 5s
      retries: 5

  # TimescaleDB (PostgreSQL with time-series extension)
  timescale:
    image: timescale/timescaledb:latest-pg16
    container_name: nodels-timescale
    environment:
      POSTGRES_USER: nodels
      POSTGRES_PASSWORD: nodels_dev
      POSTGRES_DB: nodels_timeseries
    ports:
      - "5433:5432"
    volumes:
      - timescale_data:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U nodels"]
      interval: 10s
      timeout: 5s
      retries: 5

  # Redis (Cache & Pub/Sub)
  redis:
    image: redis:7-alpine
    container_name: nodels-redis
    ports:
      - "6379:6379"
    volumes:
      - redis_data:/data
    command: redis-server --appendonly yes
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 10s
      timeout: 5s
      retries: 5

  # Redis Commander (GUI for development)
  redis-commander:
    image: rediscommander/redis-commander:latest
    container_name: nodels-redis-ui
    environment:
      REDIS_HOSTS: local:redis:6379
    ports:
      - "8081:8081"
    depends_on:
      - redis

volumes:
  postgres_data:
  timescale_data:
  redis_data:
