services:
    app:
        build:
            context: .
            dockerfile: Dockerfile
        container_name: laravel_app
        working_dir: /var/www/html
        volumes:
            - .:/var/www/html
        depends_on:
            - db
        networks:
            - laravel_network
        extra_hosts:
            - "host.docker.internal:host-gateway"

    web:
        image: nginx:latest
        container_name: nginx_web
        ports:
            - "8000:80"
        volumes:
            - .:/var/www/html
            - ./.docker/nginx/nginx.conf:/etc/nginx/conf.d/default.conf
        depends_on:
            - app
        networks:
            - laravel_network

    db:
        image: mysql:8.0
        container_name: mysql_db
        restart: always
        ports:
            - "3306:3306"
        environment:
            MYSQL_ROOT_PASSWORD: root
            MYSQL_DATABASE: laravel
            MYSQL_USER: laravel
            MYSQL_PASSWORD: secret
        volumes:
            - dbdata:/var/lib/mysql
        networks:
            - laravel_network

networks:
    laravel_network:

volumes:
    dbdata:
