version: "3.5"

services:
    db:
        image: mysql:latest
        restart: unless-stopped
        environment:
            - MYSQL_DATABASE=$DB_DATABASE
            - MYSQL_USER=$DB_USERNAME
            - MYSQL_PASSWORD=$DB_PASSWORD
            - MYSQL_RANDOM_ROOT_PASSWORD=true
        volumes:
            - $PWD/docker/initdb:/docker-entrypoint-initdb.d
            - $PWD/conf/mysql.cnf:/etc/mysql/conf.d/mysql-add.cnf
        command: --default-authentication-plugin=mysql_native_password
        ports:
            - ${EXT_DB_PORT:-3306}:3306
        networks:
            - bpdlh
            
    db-admin:
        image: adminer
        restart: unless-stopped
        ports:
            - ${EXT_DB_ADMIN_PORT:-8080}:8080
        depends_on:
            - db
        networks:
            - bpdlh

networks:
    bpdlh: