version: '2'
services:
    apache:
        build:
            context: .
            dockerfile: _twinkl_ide/docker/apache2/Dockerfile
        container_name: twinkl_test_apache
        ports:
            - "8080:8080"
        expose:
            - "8080"
        environment:
            - FPM_SOCK=twinkl_test_php_fpm
        volumes:
            - ./Sites:/Sites
            - ./_twinkl_ide/docker/apache2/conf/httpd.conf:/usr/local/apache2/conf/httpd.conf
            - ./_twinkl_ide/docker/apache2/sites-enabled:/usr/local/apache2/sites-enabled
        command: ["/usr/local/apache2/bin/apachectl", "-D",  "FOREGROUND"]
    php_fpm:
        build:
            context: .
            dockerfile: _twinkl_ide/docker/php/Dockerfile
        container_name: twinkl_test_php_fpm
        volumes:
            -  ./Sites:/Sites
            -  ./_twinkl_ide/docker/php/conf/custom.ini:/usr/local/etc/php/conf.d/custom.ini
            - ./_twinkl_ide/docker/php/conf/docker-php-ext-xdebug.ini:/usr/local/etc/php/conf.d/xdebug.ini
    db:
        image: mysql:5.7
        container_name: twinkl_test_mysql
        ports:
            - "3306:3306"
        expose:
            - "3306"
        environment:
            - MYSQL_ALLOW_EMPTY_PASSWORD=0
            - MYSQL_ROOT_HOST=%
            - MYSQL_DATABASE=sites_default
            - MYSQL_USER=twinkl
            - MYSQL_PASSWORD=twinkl
            - MYSQL_ROOT_PASSWORD=root
        command: ["mysqld", "--sql-mode=ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"]
        volumes:
            - ./_twinkl_ide/docker/mysql/:/docker-entrypoint-initdb.d/
            - ./_twinkl_ide/docker/mysql/conf/my.cnf:/etc/mysql/mysql.cnf
    phpmyadmin:
        image: phpmyadmin/phpmyadmin
        links:
            - "db"
        container_name: twinkl_test_phpmyadmin
        environment:
            - PMA_HOST=db
        restart: always
        ports:
            - "8084:80"