version: '3.9'
services:
  mariadb_primary:
    image: mariadb:10.11
    environment:
      MARIADB_ROOT_PASSWORD_FILE: /run/secrets/mysql_root_password_file
      MARIADB_DATABASE: mariadb
    secrets:
    - mysql_root_password_file
    command:
    - --log-bin=mysql-bin
    - --server-id=1
    volumes:
    - mariadb_data:/var/lib/mysql
    networks:
    - database-network
    deploy:
      placement:
        constraints:
        - node.labels.role==db
      replicas: 1
volumes:
  mariadb_data:
    driver: local
secrets:
  mysql_root_password_file:
    external: true
networks:
  database-network:
    external: true
