services:
  redis:
    image: redis:7-alpine
    command: ["redis-server", "--appendonly", "yes"]
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 5s
      timeout: 3s
      retries: 20
    ports:
      - "${EEP_REDIS_HOST_PORT:-6379}:6379"
    volumes:
      - redis-data:/data

  postgres:
    image: postgres:16-alpine
    environment:
      POSTGRES_USER: eep
      POSTGRES_PASSWORD: eep
      POSTGRES_DB: eep
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U eep -d eep"]
      interval: 5s
      timeout: 3s
      retries: 20
    ports:
      - "${EEP_POSTGRES_HOST_PORT:-5432}:5432"
    volumes:
      - postgres-data:/var/lib/postgresql/data

  node-api:
    build:
      # EEP repository root (contains packages/ and examples/)
      context: ../..
      dockerfile: examples/eep-reference-implementation/node/Dockerfile
    environment:
      PORT: "3100"
      EEP_DATABASE_URL: postgresql://eep:eep@postgres:5432/eep
      EEP_REDIS_URL: redis://redis:6379
    depends_on:
      postgres:
        condition: service_healthy
      redis:
        condition: service_healthy
    healthcheck:
      test: ["CMD-SHELL", "wget -qO- http://localhost:3100/healthz | grep -q '\"ok\":true'"]
      interval: 10s
      timeout: 5s
      retries: 20
    ports:
      - "${EEP_NODE_API_PORT:-3100}:3100"

  python-api:
    build:
      context: ../..
      dockerfile: examples/eep-reference-implementation/python/Dockerfile
    environment:
      EEP_DATABASE_URL: postgresql://eep:eep@postgres:5432/eep
      EEP_REDIS_URL: redis://redis:6379
    depends_on:
      postgres:
        condition: service_healthy
      redis:
        condition: service_healthy
    healthcheck:
      test: ["CMD-SHELL", "wget -qO- http://localhost:3200/healthz | grep -q '\"ok\":true'"]
      interval: 10s
      timeout: 5s
      retries: 20
    ports:
      - "${EEP_PYTHON_API_PORT:-3200}:3200"

volumes:
  redis-data:
  postgres-data:
