version: '3.8'

services:
  # Infrastructure
  postgres:
    image: postgres:15
    environment:
      POSTGRES_DB: women_safety_test
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: postgres
    ports:
      - "5433:5432"
    volumes:
      - postgres_test_data:/var/lib/postgresql/data

  redis:
    image: redis:7-alpine
    ports:
      - "6380:6379"

  # Microservices
  api-gateway:
    image: women-safety/api-gateway:latest
    ports:
      - "8000:8000"
    environment:
      - USER_SERVICE_URL=http://user-service:8001
      - EMERGENCY_SERVICE_URL=http://emergency-service:8002
      - LOCATION_SERVICE_URL=http://location-service:8003
      - CALENDAR_SERVICE_URL=http://calendar-service:8004
      - NOTIFICATION_SERVICE_URL=http://notification-service:8005
    depends_on:
      - user-service
      - emergency-service
      - location-service
      - calendar-service
      - notification-service

  user-service:
    image: women-safety/user-service:latest
    ports:
      - "8001:8001"
    environment:
      - DATABASE_URL=postgresql://postgres:postgres@postgres:5432/women_safety_test
      - REDIS_URL=redis://redis:6379/0
      - JWT_SECRET_KEY=test-secret-key-for-testing
    depends_on:
      - postgres
      - redis

  emergency-service:
    image: women-safety/emergency-service:latest
    ports:
      - "8002:8002"
    environment:
      - DATABASE_URL=postgresql://postgres:postgres@postgres:5432/women_safety_test
      - REDIS_URL=redis://redis:6379/1
      - LOCATION_SERVICE_URL=http://location-service:8003
      - NOTIFICATION_SERVICE_URL=http://notification-service:8005
    depends_on:
      - postgres
      - redis

  location-service:
    image: women-safety/location-service:latest
    ports:
      - "8003:8003"
    environment:
      - DATABASE_URL=postgresql://postgres:postgres@postgres:5432/women_safety_test
      - REDIS_URL=redis://redis:6379/2
    depends_on:
      - postgres
      - redis

  calendar-service:
    image: women-safety/calendar-service:latest
    ports:
      - "8004:8004"
    environment:
      - DATABASE_URL=postgresql://postgres:postgres@postgres:5432/women_safety_test
      - REDIS_URL=redis://redis:6379/3
      - NOTIFICATION_SERVICE_URL=http://notification-service:8005
    depends_on:
      - postgres
      - redis

  notification-service:
    image: women-safety/notification-service:latest
    ports:
      - "8005:8005"
    environment:
      - DATABASE_URL=postgresql://postgres:postgres@postgres:5432/women_safety_test
      - REDIS_URL=redis://redis:6379/4
      - FCM_SERVER_KEY=test-fcm-key
    depends_on:
      - postgres
      - redis

volumes:
  postgres_test_data: