version: '3.9'

services:
  mariadb_primary:
    image: mariadb:10.11
    environment:
      MYSQL_ROOT_PASSWORD_FILE: /run/secrets/mariadb_root_password
    secrets:
      - mariadb_root_password
    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:
  mariadb_root_password:
    external: true

networks:
  database-network:
    external: true
