version: '3.9'

networks:
  monitor-net:
    driver: bridge
    ipam:
      config:
        - subnet: 10.5.0.0/24
          gateway: 10.5.0.1

services:
  prometheus:
    user: {{ prometheus_uid }}:{{ prometheus_gid }}
    image: {{ _prometheus_image }}
    container_name: prometheus
    restart: unless-stopped
    volumes:
      - type: bind
        source: {{ _prometheus_config_directory }}
        target: /etc/prometheus
      - type: bind
        source: {{ _prometheus_db_directory }}
        target: /data
    command:
      - '--config.file=/etc/prometheus/prometheus.yml'
      - '--storage.tsdb.path=/data'
      - '--web.console.libraries=/usr/share/prometheus/console_libraries'
      - '--web.console.templates=/usr/share/prometheus/consoles'
    ports:
      - 9090:9090
    networks:
      monitor-net:
        ipv4_address: 10.5.0.2

  alertmanager:
    user: {{ prometheus_uid }}:{{ prometheus_gid }}
    image: {{ _alertmanager_image }}
    container_name: alertmanager
    restart: unless-stopped
    volumes:
      - type: bind
        source: {{ _alertmanager_config_directory }}
        target: /etc/alertmanager
      - type: bind
        source: {{ _alertmanager_db_directory }}
        target: /alertmanager
    command:
      - '--config.file=/etc/alertmanager/alertmanager.yml'
      - '--storage.path=/alertmanager'
    ports:
      - 9093:9093
    networks:
      monitor-net:
        ipv4_address: 10.5.0.3

  grafana:
    image: {{ _grafana_image }}
    container_name: grafana
    restart: unless-stopped
    volumes:
      - type: bind
        source: {{ _grafana_config_directory }}
        target: /etc/grafana/provisioning
      - type: bind
        source: {{ _grafana_data_directory }}
        target: /var/lib/grafana
    environment:
      - GF_SECURITY_ADMIN_USER={{ _grafana_init_user }}
      - GF_SECURITY_ADMIN_PASSWORD={{ _grafana_init_user_pass }}
      - GF_USERS_ALLOW_SIGN_UP=false
    ports:
      - 3000:3000
    networks:
      monitor-net:
        ipv4_address: 10.5.0.4