services:
  mariadb:
    image: mariadb:11.4
    container_name: mariadb-node${MGDB_NODE_NUMBER}
    restart: always
    network_mode: host
    environment:
      - MARIADB_ROOT_PASSWORD=${DB_ROOT_PASSWORD}
      - MARIADB_USER=${DB_ADMIN_USER}
      - MARIADB_PASSWORD=${DB_ADMIN_PASSWORD}
      - MARIADB_DATABASE=initial_db
    volumes:
      - /docker/maria/data:/var/lib/mysql
      - /docker/maria/conf:/etc/mysql/conf.d
      - /docker/maria/init:/docker-entrypoint-initdb.d
    command:
      - mariadbd
      - --wsrep-on=ON
      - --wsrep-provider=/usr/lib/galera/libgalera_smm.so
      - --wsrep-cluster-name=mgdev1
      - --bind-address=0.0.0.0
      - --wsrep-cluster-address=gcomm://${CLUSTER_PRI_IP},${CLUSTER_SEC_IP},${CLUSTER_ARB_IP}${MGDB_NOTE_PRI}
      - --wsrep-node-address=${MGDB_LOCAL_IP}
      - --wsrep-node-name=node${MGDB_NODE_NUMBER}
      - --binlog-format=row
      - --innodb-autoinc-lock-mode=2
      - --wsrep-sst-method=mariabackup
      - --wsrep-sst-auth=sstuser:${REPL_PASSWORD}
      # No manual weights needed anymore. Default weight=1 is perfect.
      - --wsrep-provider-options=pc.ignore_sb=true;pc.npvo=true


      # Pass these through for the init script
      #- APP_REGISTRY=${APP_REGISTRY}
      #- REPL_USER=${REPL_USER}
      #- REPL_PASSWORD=${REPL_PASSWORD}
      # Dynamic password variables for your apps
      #- FORGEJO_DB_PASS=${FORGEJO_DB_PASS}
      #- GUACAMOLE_DB_PASS=${GUACAMOLE_DB_PASS}
      #- GRAFANA_DB_PASS=${GRAFANA_DB_PASS}