version: "3"
services:
    npm:
        image: node:17.3.1
        working_dir: /var/www/
        entrypoint: [ "npm" ]
        volumes:
            - ./:/var/www
    bhs-app:
        build:
            context: .
            dockerfile: Dockerfile
        working_dir: /var/www/
        volumes:
            - ./:/var/www
        networks:
            - bhs-network
        links:
            - bhs-db
            - bhs-testdb
        depends_on:
            - bhs-db
    bhs-db:
        image: mysql:5.7
        restart: unless-stopped
        ports:
            - 8889:3306
        environment:
            MYSQL_DATABASE: bhs
            MYSQL_PASSWORD: dbpass
            MYSQL_USER: dbuser
            MYSQL_RANDOM_ROOT_PASSWORD: "yes"
        volumes:
            - bhs-data:/var/lib/mysql
        networks:
            - bhs-network

    bhs-testdb:
        image: mysql:5.7
        ports:
            - 8888:3306
        environment:
            MYSQL_DATABASE: bhs_tests
            MYSQL_PASSWORD: dbpass
            MYSQL_USER: dbuser
            MYSQL_RANDOM_ROOT_PASSWORD: "yes"
        tmpfs: /var/lib/mysql
        networks:
            - bhs-network

    phpmyadmin:
        image: phpmyadmin/phpmyadmin
        networks:
            - bhs-network
        environment:
            PMA_HOST: bhs-db
        restart: always
        ports:
            - 8082:80
        links:
            - bhs-db
        depends_on:
            - bhs-db

    nginx:
        image: nginx:alpine
        restart: unless-stopped
        ports:
            - 8000:80
        volumes:
            - ./:/var/www
            - ./docker:/etc/nginx/conf.d/
        networks:
            - bhs-network

networks:
    bhs-network:
        driver: bridge
volumes:
    bhs-data:
