version: '3.8'

# Test environment for IAM Service integration tests
# Run with: docker-compose -f docker-compose.test.yml up -d

services:
  # PostgreSQL test database
  postgres-test:
    image: postgres:15-alpine
    container_name: postgres-test-iam
    environment:
      POSTGRES_USER: test
      POSTGRES_PASSWORD: test
      POSTGRES_DB: test_iam_db
    ports:
      - "5433:5432"  # Different port to avoid conflicts
    volumes:
      - postgres_test_data:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U test -d test_iam_db"]
      interval: 5s
      timeout: 5s
      retries: 5
    networks:
      - test-network

  # Redis test cache
  redis-test:
    image: redis:7-alpine
    container_name: redis-test-iam
    ports:
      - "6380:6379"  # Different port to avoid conflicts
    volumes:
      - redis_test_data:/data
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 5s
      timeout: 3s
      retries: 5
    networks:
      - test-network

volumes:
  postgres_test_data:
    driver: local
  redis_test_data:
    driver: local

networks:
  test-network:
    driver: bridge