version: '2'
services:
  node1-mariadb:
    image: hauptmedia/mariadb:10.1
    hostname: node1-mariadb
    container_name: node1-mariadb
    environment:
      MYSQL_ROOT_PASSWORD: 'iamgroot'
      REPLICATION_PASSWORD: 'iamgroot'
      GALERA: 'On'
      NODE_NAME: node1-mariadb
      CLUSTER_NAME: maria_cluster
      CLUSTER_ADDRESS: gcomm://
      TZ : 'Asia/Seoul'
    ports:
      - 13306:3306/tcp
    volumes:
      - ./galeranode1/mariadb:/var/lib/mysql
      - ./sqldir:/docker-entrypoint-initdb.d
    command:
      --wait_timeout=28800
      --character-set-server=utf8
      --collation-server=utf8_general_ci
      --max-allowed-packet=512M
      --net-buffer-length=5048576
      --wsrep-new-cluster
    stdin_open: true
    tty: true
    privileged: true
    ulimits:
      nofile:
        soft: 600000
        hard: 640000


  node2-mariadb:
    image: hauptmedia/mariadb:10.1
    hostname: node2-mariadb
    container_name: node2-mariadb
    links:
      - node1-mariadb
    environment:
      REPLICATION_PASSWORD: 'iamgroot'
      GALERA: 'On'
      NODE_NAME: node2-mariadb
      CLUSTER_NAME: maria_cluster
      CLUSTER_ADDRESS: gcomm://node1-mariadb
      TZ : 'Asia/Seoul'
    ports:
      - 23306:3306/tcp
    volumes:
      - ./galeranode2/mariadb:/var/lib/mysql
    command:
      --wait_timeout=28800
      --character-set-server=utf8
      --collation-server=utf8_general_ci
      --max-allowed-packet=512M
      --net-buffer-length=5048576
    stdin_open: true
    tty: true
    privileged: true
    depends_on:
      - node1-mariadb
    ulimits:
      nofile:
        soft: 600000
        hard: 640000

  node3-mariadb:
    image: hauptmedia/mariadb:10.1
    hostname: node3-mariadb
    container_name: node3-mariadb
    links:
      - node1-mariadb
    environment:
      REPLICATION_PASSWORD: 'iamgroot'
      GALERA: 'On'
      NODE_NAME: node3-mariadb
      CLUSTER_NAME: maria_cluster
      CLUSTER_ADDRESS: gcomm://node1-mariadb
      TZ : 'Asia/Seoul'
    ports:
      - 33306:3306/tcp
    volumes:
      - ./galeranode3/mariadb:/var/lib/mysql
    command:
      --wait_timeout=28800
      --character-set-server=utf8
      --collation-server=utf8_general_ci
      --max-allowed-packet=512M
      --net-buffer-length=5048576
    stdin_open: true
    tty: true
    privileged: true
    depends_on:
      - node1-mariadb
      - node2-mariadb