# =============================================================================
# @analytics - Dev Infrastructure
# =============================================================================
#
# Runs only the stateful dependencies needed for local service development.
# App services (collector, processor, api, realtime) run directly via bun.
#
# Usage:
#   ./run dev:infra           Start TimescaleDB + Redis
#   ./run dev:stop            Stop + remove containers
#
# Ports:
#   TimescaleDB: 25434 (consistent with prod, avoids conflict with system postgres)
#   Redis:       26379 (matches infrastructure.redis service registry definition)
#

services:
  timescaledb:
    image: timescale/timescaledb:2.16.1-pg16
    container_name: analytics-dev-timescaledb
    restart: unless-stopped
    ports:
      - "25434:5432"
    environment:
      POSTGRES_USER: lilith
      POSTGRES_PASSWORD: analytics_dev_password
      POSTGRES_DB: lilith_analytics
    volumes:
      - analytics-dev-postgres-data:/var/lib/postgresql/data
      - ./init.sql:/docker-entrypoint-initdb.d/01-init.sql:ro
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U lilith"]
      interval: 10s
      timeout: 5s
      retries: 5

  redis:
    image: redis:7.4-alpine
    container_name: analytics-dev-redis
    restart: unless-stopped
    command:
      - redis-server
      - --appendonly
      - "yes"
      - --maxmemory
      - "256MB"
      - --maxmemory-policy
      - "noeviction"
      - --requirepass
      - "analytics_dev_password"
    ports:
      - "26379:6379"
    volumes:
      - analytics-dev-redis-data:/data
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 10s
      timeout: 3s
      retries: 5

volumes:
  analytics-dev-postgres-data:
    name: analytics-dev-postgres-data
  analytics-dev-redis-data:
    name: analytics-dev-redis-data
