version: '3'
services:
  temp-db:
{% if (ansible_become == true and ansible_become_user == 'root') or ansible_user == 'root' %}
    user: {{uid}}:{{gid}}
    command: {{ command }} --user={{ uid }} {{ flags }}
{% else %}
    user: root:0
    command: {{ command }} --user=root {{ flags }}
{% endif %}
    image: {{container}}
    hostname: temp-db
    environment:
      - MYSQL_USER={{db_user}}
      - MYSQL_PASSWORD={{db_passwd}}
      - MYSQL_DATABASE={{db}}
      - MYSQL_ROOT_PASSWORD={{ root_passwd }}
      - MARIADB_USER={{db_user}}
      - MARIADB_PASSWORD={{db_passwd}}
      - MARIADB_DATABASE={{db}}
      - MARIADB_ALLOW_EMPTY_ROOT_PASSWORD=1
      - MYSQL_ALLOW_EMPTY_ROOT_PASSWORD=1
      - MARIADB_ROOT_PASSWORD={{ root_passwd }}
    volumes:
      - data:/var/lib/mysql:rw
      - backup:/backup:rw
    container_name: temp-db
    tty: true

volumes:
  data:
  backup:
