version: '3'
services:
  {{db_name}}:
{% if (ansible_become == true and ansible_become_user == 'root') or ansible_user == 'root' %}
    user: {{uid}}:{{gid}}
{% else %}
    user: root:0
{% endif %}
    image: ghcr.io/freva-org/freva-mysql:{{db_version}}
    hostname: {{db_name}}
    environment:
      - ROOT_PW={{ root_passwd }}
      - HOST={{ db_host }}
      - PROJECT={{ project_name }}
      - MYSQL_USER={{db_user}}
      - MYSQL_PASSWORD={{db_passwd}}
      - MYSQL_DATABASE={{db}}
      - MYSQL_ROOT_PASSWORD={{ root_passwd }}
    volumes:
      - data:/data/db:z
      - logs:/data/logs:z
    container_name: {{db_name}}
    tty: true
    ports:
      - {{db_port}}:3306
volumes:
  data:
  logs:
