services:
  db:
    image: mariadb:11
    container_name: icinga-db
    command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
    environment:
      MARIADB_ROOT_PASSWORD: change-me-root
      MARIADB_DATABASE: icinga
      MARIADB_USER: icinga
      MARIADB_PASSWORD: change-me-icinga
    volumes:
      - ./data/db:/var/lib/mysql
    networks:
      - monitoring
    restart: unless-stopped

  redis:
    image: redis:7-alpine
    container_name: icinga-redis
    command: ["redis-server", "--port", "6380"]
    networks:
      - monitoring
    restart: unless-stopped

  icinga2:
    image: icinga/icinga2:2.14
    container_name: icinga2
    environment:
      ICINGA2_FEATURE_GRAPHITE: "0"
    volumes:
      - ./data/icinga2/etc:/etc/icinga2
      - ./data/icinga2/var:/var/lib/icinga2
      - ./data/icinga2/log:/var/log/icinga2
      - ./data/icinga2/cache:/var/cache/icinga2
    networks:
      - monitoring
    restart: unless-stopped

  icingaweb2:
    image: icinga/icingaweb2:2.12
    container_name: icingaweb2
    depends_on:
      - db
      - icinga2
    environment:
      # Web Setup läuft über UI, DB-Zugang ist trotzdem nötig:
      ICINGAWEB2_DB_TYPE: mysql
      ICINGAWEB2_DB_HOST: db
      ICINGAWEB2_DB_NAME: icinga
      ICINGAWEB2_DB_USERNAME: icinga
      ICINGAWEB2_DB_PASSWORD: change-me-icinga
    volumes:
      - ./data/icingaweb2/config:/etc/icingaweb2
      - ./data/icingaweb2/data:/var/lib/icingaweb2
    ports:
      - "8082:8080"   # intern 8080 -> außen 8081 (für Nginx Proxy)
    networks:
      - monitoring
    restart: unless-stopped

networks:
  monitoring:
    name: monitoring
