version: '3.3'
services:
 

  zabbix-server:     # The main Zabbix Server Software Service
    logging:
      driver: loki
      options:
        loki-url: "http://localhost:3100/loki/api/v1/push"
    image: zabbix/zabbix-server-mysql:6.4-ubuntu-latest
    container_name: zabbix-server
    restart: unless-stopped
    environment:   # The Postgres database value variable
      DB_SERVER_HOST: mysql-zabbix
      MYSQL_USER: zabbix
      MYSQL_PASSWORD: eccmts42*
      MYSQL_DATABASE: zabbix
      ZBX_HISTORYSTORAGETYPES: log,text #Zabbix configuration variables
      ZBX_DEBUGLEVEL: 1
      ZBX_HOUSEKEEPINGFREQUENCY: 1
      ZBX_MAXHOUSEKEEPERDELETE: 5000
    ports: 
      - "10051:10051"
    depends_on:
      - mysql-zabbix
    links:
      - mysql-zabbix
#      - zabbix-postfix
    volumes:  # Volumes for scripts and related files you can add
      - /home/icke/zabbix-server/alertscripts:/usr/lib/zabbix/alertscripts
      - /home/icke/zabbix-server/externalscripts:/usr/lib/zabbix/externalscripts
      - /home/icke/zabbix-server/userparameter_diskstats.conf:/etc/zabbix/zabbix_agentd.d/userparameter_diskstats.conf
      - /home/icke/zabbix-server/lld-disks.py:/usr/local/bin/lld-disks.py
    networks:
      zabbix:
        ipv4_address: 172.19.0.2

#  zabbix-agent:   # Zabbix agent service that tracks usage and send to zabbix server
#    image: zabbix/zabbix-agent:latest
#    container_name: zabbix-agent
#    privileged: true   #access mode for allowing resource access
#    #network_mode: "host"
#    links:
#      - zabbix-server
#    restart: unless-stopped
#    environment:
#      - ZBX_SERVER_HOST=172.19.0.2 #the IP/Dns of Zabbix server
#    networks:
#      zabbix:
#        ipv4_address: 172.19.0.3
 # zabbix-postfix:
 #   ports:
 #     - "25:25"
 #   image: catatnight/postfix
 #   container_name: zabbix-postfix
 #   environment:
 #     smtp_user: monitor:eccmts42*
 #     maildomain: mail.egonetix.de
  
  zabbix-web:    # The main Zabbix web UI or interface 
    logging:
      driver: loki
      options:
        loki-url: "http://localhost:3100/loki/api/v1/push"
    image: zabbix/zabbix-web-nginx-mysql:6.4-ubuntu-latest
    container_name: zabbix-web
    restart: unless-stopped
    environment:  # Postgre database variables
      DB_SERVER_HOST: mysql-zabbix
      MYSQL_USER: zabbix
      MYSQL_PASSWORD: eccmts42*
      MYSQL_DATABASE: zabbix
      ZBX_SERVER_HOST: zabbix-server  # Zabbix related and Php variables
      ZBX_POSTMAXSIZE: 64M
      PHP_TZ: "Europe/Berlin"  
      ZBX_MAXEXECUTIONTIME: 500
    links:
      - mysql-zabbix
      - zabbix-server
    depends_on:
      - mysql-zabbix
      - zabbix-server
    ports:    # Port where Zabbix UI is available
      - "8084:8080"
    networks:
      zabbix:
        ipv4_address: 172.19.0.4
  mysql-zabbix:
   #image: mariadb:10.6
    logging:
      driver: loki
      options:
        loki-url: "http://localhost:3100/loki/api/v1/push"
    image: mysql:8.0
    container_name: mysql-zabbix
    command: --innodb-buffer-pool-size=2G --innodb-log-file-size=256M --max-connections=150 --innodb-flush-log-at-trx-commit=2
#    ports:
#     - "6603:3306"
    environment:
#     - default-authentication-plugin=mysql_native_password
     - MYSQL_ROOT_PASSWORD=eccmts42*
     - MYSQL_DATABASE=zabbix
     - MYSQL_USER=zabbix
     - MYSQL_PASSWORD=eccmts42*
    volumes:
     - /home/icke/mysql-zabbix/var:/var/lib/mysql
     - /home/icke/mysql-zabbix/performance.cnf:/etc/mysql/conf.d/performance.cnf:ro
    restart: unless-stopped
    networks:
      zabbix:
        ipv4_address: 172.19.0.5

networks:
  zabbix:
    driver: bridge
    ipam:
     config:
       - subnet: 172.19.0.0/29

volumes:
  zabbix-server:
  zabbix-web:
  mysql-zabbix:
#  zabbix-postfix:
#  zabbix-agent:
