version: '3.8'

services:
    app:
        build:
            context: .
            dockerfile: Dockerfile
        image: laravel-app
        container_name: laravel-app
        restart: unless-stopped
        user: "${UID}:${GID}"
        environment:
            - UID=1000
            - GID=1001
        volumes:
            - .:/var/www
        networks:
            - laravel

    webserver:
        image: nginx:alpine
        container_name: laravel-nginx
        restart: unless-stopped
        ports:
            - "8000:80"
        volumes:
            - .:/var/www
            - ./nginx.conf:/etc/nginx/conf.d/default.conf
        depends_on:
            - app
        networks:
            - laravel

    db:
        image: mysql:8.0
        container_name: laravel-db
        restart: unless-stopped
        ports:
            - "3307:3306"
        environment:
            MYSQL_DATABASE: laravel
            MYSQL_ROOT_PASSWORD: secret
            MYSQL_USER: laravel
            MYSQL_PASSWORD: secret
        volumes:
            - dbdata:/var/lib/mysql
        networks:
            - laravel

networks:
    laravel:

volumes:
    dbdata:
