version: '3.8'
services:
    app:
        build:
            context: .
            dockerfile: Dockerfile
        container_name: laravel-app
        working_dir: /var/www
        volumes:
            - './:/var/www'
        ports:
            - '8000:8000'
        environment:
            - DB_HOST=mysql
            - DB_PORT=3306
            - 'DB_DATABASE=${DB_DATABASE}'
            - 'DB_USERNAME=${DB_USERNAME}'
            - 'DB_PASSWORD=${DB_PASSWORD}'
            - REDIS_HOST=redis
            - REDIS_PORT=6379
        depends_on:
            - mysql
            - redis
        networks:
            - laravel-net
    mysql:
        image: 'mysql:8.0'
        container_name: laravel-mysql
        ports:
            - '3306:3306'
        environment:
            MYSQL_DATABASE: '${DB_DATABASE}'
            MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}'
            MYSQL_USER: '${DB_USERNAME}'
            MYSQL_PASSWORD: '${DB_PASSWORD}'
        volumes:
            - 'mysql-data:/var/lib/mysql'
        networks:
            - laravel-net
    redis:
        image: 'redis:7-alpine'
        container_name: laravel-redis
        ports:
            - '6379:6379'
        networks:
            - laravel-net
    mailpit:
        image: 'axllent/mailpit:latest'
        ports:
            - '${FORWARD_MAILPIT_PORT:-1025}:1025'
            - '${FORWARD_MAILPIT_DASHBOARD_PORT:-8025}:8025'
        networks:
            - sail
volumes:
    mysql-data: null
    sail-mysql:
        driver: local
    sail-redis:
        driver: local
networks:
    laravel-net:
        driver: bridge
