version: "3.8"

services:
    app:
        build:
            context: .
            dockerfile: Dockerfile
        ports:
            - "9000:9000"
        volumes:
            - ./:/var/www/html
        depends_on:
            - db
        networks:
            - app-network

    db:
        image: mysql:8.0
        ports:
            - "3306:3306"
        environment:
            MYSQL_ROOT_PASSWORD: password
            MYSQL_DATABASE: laravel
            MYSQL_USER: user
            MYSQL_PASSWORD: password
        volumes:
            - db_data:/var/lib/mysql
        networks:
            - app-network

    nginx:
        image: nginx:latest
        ports:
            - "8000:80"
        volumes:
            - ./public:/var/www/html/public
            - ./nginx/conf.d:/etc/nginx/conf.d
        depends_on:
            - app
        networks:
            - app-network
    npm:
        image: node:14
        working_dir: /var/www/my_shiny_project
        entrypoint: ["npm"]
        volumes:
            - "./www/:/var/www/my_shiny_project"
volumes:
    db_data:

networks:
    app-network:
        driver: bridge
