services:
    app:
        build:
            args:
                user: bossy
                uid: 1000
            context: ./
            dockerfile: Dockerfile
        image: bossy
        container_name: bossy-app
        restart: unless-stopped
        working_dir: /home/bossy/public_html
        volumes:
            - ./:/home/bossy/public_html
            - ./docker-compose/php/custom-php.ini:/usr/local/etc/php/conf.d/custom-php.ini
        depends_on:
            - db
            - redis
        networks:
            - bossy
        environment:
            - SHELL=/bin/bash
        stdin_open: true
        tty: true

    db:
        image: mariadb:10.6
        container_name: bossy-db
        restart: unless-stopped
        ports:
            - "3306:3306"
        environment:
            MYSQL_DATABASE: ${DB_DATABASE}
            MYSQL_USER: ${DB_USERNAME}
            MYSQL_PASSWORD: ${DB_PASSWORD}
            MYSQL_ROOT_PASSWORD: ${DB_PASSWORD}
            SERVICE_TAGS: local
            SERVICE_NAME: mysql
        volumes:
            - ./docker-compose/mysql:/docker-entrypoint-initdb.d
            - db_data:/var/lib/mysql
        networks:
            - bossy

    redis:
        image: redis:6.0.2
        container_name: bossy-redis
        restart: unless-stopped
        ports:
            - "6379:6379"
        networks:
            - bossy

    horizon:
        build:
            context: ./
            dockerfile: Dockerfile
            args:
                user: bossy
                uid: 1000
        image: bossy-horizon
        container_name: bossy-horizon
        restart: unless-stopped
        working_dir: /home/bossy/public_html
        command: php artisan horizon
        user: root
        volumes:
            - ./:/home/bossy/public_html
            - ./docker-compose/php/custom-php.ini:/usr/local/etc/php/conf.d/custom-php.ini
        depends_on:
            - redis
            - db
        networks:
            - bossy

    nginx:
        image: nginx:alpine
        container_name: bossy-nginx
        restart: unless-stopped
        ports:
            - "8000:80"
        volumes:
            - ./:/home/bossy/public_html
            - ./docker-compose/nginx:/etc/nginx/conf.d/
        depends_on:
            - app
        networks:
            - bossy

networks:
    bossy:
        driver: bridge

volumes:
    db_data:
