services:
  soc-integrator-db:
    image: postgres:16-alpine
    container_name: soc-integrator-db
    hostname: soc-integrator-db
    restart: unless-stopped
    env_file:
      - ../soc-integrator/.env.example
      - ../soc-integrator/.env
    environment:
      - POSTGRES_DB=${SOC_INTEGRATOR_DB_NAME:-soc_integrator}
      - POSTGRES_USER=${SOC_INTEGRATOR_DB_USER:-soc_integrator}
      - POSTGRES_PASSWORD=${SOC_INTEGRATOR_DB_PASSWORD:-soc_integrator_password}
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U ${SOC_INTEGRATOR_DB_USER:-soc_integrator} -d ${SOC_INTEGRATOR_DB_NAME:-soc_integrator}"]
      interval: 10s
      timeout: 5s
      retries: 5
    volumes:
      - soc-integrator-db-data:/var/lib/postgresql/data
    networks:
      - soc_shared

  soc-integrator:
    build:
      context: ../soc-integrator
      dockerfile: Dockerfile
    container_name: soc-integrator
    hostname: soc-integrator
    restart: unless-stopped
    env_file:
      - ../soc-integrator/.env.example
      - ../soc-integrator/.env
    environment:
      - APP_ENV=${APP_ENV:-dev}
      - LOG_LEVEL=${LOG_LEVEL:-INFO}
    ports:
      - "${SOC_INTEGRATOR_PORT:-8088}:8080"
    depends_on:
      soc-integrator-db:
        condition: service_healthy
    networks:
      - soc_shared

volumes:
  soc-integrator-db-data:

networks:
  soc_shared:
    external: true
    name: ${SOC_SHARED_NETWORK:-soc_shared}
