services:
    app:
        build:
            context: .
            dockerfile: Dockerfile
        image: habibcables-erp-app
        container_name: habibcables-erp-app
        working_dir: /var/www/html
        volumes:
            - ./:/var/www/html
        ports:
            - "9000:9000"
        environment:
            APP_ENV: local
            APP_DEBUG: "true"
            DB_CONNECTION: mysql
            DB_HOST: db
            DB_PORT: 3306
            DB_DATABASE: habib_cables
            DB_USERNAME: root
            DB_PASSWORD: secret
            REDIS_HOST: redis
            QUEUE_CONNECTION: database
            SESSION_DRIVER: database
            CACHE_STORE: database
            FILESYSTEM_DISK: local
        depends_on:
            - db
            - redis
        networks:
            - laravel

    web:
        image: nginx:stable-alpine
        container_name: habibcables-erp-web
        depends_on:
            - app
        ports:
            - "8000:80"
        volumes:
            - ./:/var/www/html:cached
            - ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf:ro
        networks:
            - laravel

    node:
        image: node:20
        container_name: habibcables-erp-node
        working_dir: /var/www/html
        volumes:
            - ./:/var/www/html
        command: ["npm", "run", "dev", "--", "--host", "0.0.0.0"]
        ports:
            - "5173:5173"
        networks:
            - laravel

    redis:
        image: redis:alpine
        container_name: habibcables-erp-redis
        ports:
            - "6379:6379"
        networks:
            - laravel

    db:
        image: mysql:8.0
        container_name: habibcables-erp-db
        restart: unless-stopped
        environment:
            MYSQL_DATABASE: habib_cables
            MYSQL_ROOT_PASSWORD: secret
            MYSQL_PASSWORD: secret
            MYSQL_USER: habib_cables_user
            MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
        volumes:
            - mysql_data:/var/lib/mysql
        ports:
            - "3306:3306"
        networks:
            - laravel

volumes:
    mysql_data:
        driver: local

networks:
    laravel:
        driver: bridge
