services:
    nginx:
        image: 'nginx:latest'
        restart: always
        ports:
            - '80:80'
            - '443:443'
        volumes:
            - './docker/nginx/conf.d/nginx.conf:/etc/nginx/conf.d/default.conf'
            - './public:/var/www/html/public'
            - './storage:/var/www/html/storage'
            - './certs:/etc/nginx/ssl'
        depends_on:
            - colibriplus-app
        container_name: colibriplus-nginx
        networks:
            - sail

    colibriplus-app:
        build:
            context: .
            dockerfile: docker/colibriplus/Dockerfile
        volumes:
            - './:/var/www/html'
            - './docker/colibriplus/php.ini:/usr/local/etc/php/conf.d/colibriplus-php.ini'
            - './docker/colibriplus/opcache.ini:/usr/local/etc/php/conf.d/colibriplus-opcache.ini'
        stdin_open: true
        tty: true
        expose:
            - '9000'
        container_name: colibriplus-app
        depends_on:
            - database
        networks:
            - sail

    database:
        image: mysql:8.0
        restart: always
        volumes:
            - 'sail-mysql:/var/lib/mysql'
        ports:
            # Reverting to the normal MySQL port
            - '3306:3306'
        environment:
            - MYSQL_ROOT_PASSWORD=admin
            - MYSQL_DATABASE=colibriplus
        container_name: colibriplus-db
        networks:
            - sail

    node:
        image: 'node:18'
        working_dir: /var/www/html
        volumes:
            - './:/var/www/html'
        container_name: colibriplus-node
        command: 'sh -c "npm install && npm run build"'
        ports:
            - '5173:5173'
        depends_on:
            - colibriplus-app
        networks:
            - sail

    horizon:
        build:
            context: .
            dockerfile: docker/colibriplus/Dockerfile
        volumes:
            - './:/var/www/html'
        depends_on:
            - redis
        command: 'php artisan horizon'
        container_name: colibriplus-horizon
        networks:
            - sail

    redis:
        image: 'redis:latest'
        container_name: colibriplus-redis
        ports:
            # Reverting to the normal Redis port
            - '6379:6379'
        networks:
            - sail

volumes:
    sail-mysql:
        driver: local

networks:
    sail:
        driver: bridge