services:

    # ─── PHP Application ───────────────────────────────────────────────────────
    app:
        build:
            context: .
            dockerfile: Dockerfile
        container_name: rdf_audit_app
        restart: unless-stopped
        working_dir: /var/www
        volumes:
            - .:/var/www
            - ./docker/php/php.ini:/usr/local/etc/php/conf.d/custom.ini
        networks:
            - laravel
        depends_on:
            db:
                condition: service_healthy

    # ─── Nginx Web Server ──────────────────────────────────────────────────────
    nginx:
        image: nginx:alpine
        container_name: rdf_audit_nginx
        restart: unless-stopped
        ports:
            - "8082:80"
        volumes:
            - .:/var/www
            - ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf
        networks:
            - laravel
        depends_on:
            - app

    # ─── MySQL Database ────────────────────────────────────────────────────────
    db:
        image: mysql:8.0
        container_name: rdf_audit_db
        restart: unless-stopped
        environment:
            MYSQL_DATABASE: rdf_audit_checklist
            MYSQL_ROOT_PASSWORD: ""
            MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
        ports:
            - "3308:3306"
        volumes:
            - db_data:/var/lib/mysql
            - ./docker/mysql/my.cnf:/etc/mysql/conf.d/my.cnf
        networks:
            - laravel
        healthcheck:
            test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-p${DB_ROOT_PASSWORD:-secret}"]
            interval: 10s
            timeout: 5s
            retries: 5

    # ─── phpMyAdmin ────────────────────────────────────────────────────────────
    phpmyadmin:
        image: phpmyadmin:latest
        container_name: rdf_audit_phpmyadmin
        restart: unless-stopped
        ports:
            - "8083:80"
        environment:
            PMA_HOST: db
            PMA_USER: ${DB_USERNAME:-laravel}
            PMA_PASSWORD: ${DB_PASSWORD:-secret}
            UPLOAD_LIMIT: 100M
        networks:
            - laravel
        depends_on:
            db:
                condition: service_healthy

# ─── Volumes & Networks ──────────────────────────────────────────────────────
volumes:
    db_data:

networks:
    laravel:
        driver: bridge
