services:
    laravel.test:
        build:
            context: './vendor/laravel/sail/runtimes/8.4'
            dockerfile: Dockerfile
            args:
                WWWGROUP: '${WWWGROUP:-20}'
                WWWUSER: '${WWWUSER:-501}'
        image: 'sail-8.4/app'
        extra_hosts:
            - 'host.docker.internal:host-gateway'
        ports:
            - '${VITE_PORT:-5179}:5179'
        environment:
            WWWUSER: '${WWWUSER:-501}'
            WWWGROUP: '${WWWGROUP:-20}'
            LARAVEL_SAIL: 1
            XDEBUG_MODE: '${SAIL_XDEBUG_MODE:-off}'
            XDEBUG_CONFIG: '${SAIL_XDEBUG_CONFIG:-client_host=host.docker.internal}'
            IGNITION_LOCAL_SITES_PATH: '${PWD}'

            # --- Anbindung an das Mutterschiff ---
            DB_CONNECTION: mysql
            DB_HOST: global-mysql
            DB_PORT: 3306
            # Hier definieren wir nur die Haupt-Datenbank für .env
            # Die anderen beiden richtest du in Laravel ein
            DB_DATABASE: markemacht
            DB_USERNAME: root
            DB_PASSWORD: password
            MAIL_HOST: global-mailpit
            MAIL_PORT: 1025
            REDIS_HOST: global-redis
        volumes:
            - '.:/var/www/html'
        networks:
            - sail
            - proxy
        labels:
            - "traefik.enable=true"
            # Markemacht Domain
            - "traefik.http.routers.markemacht.rule=Host(`markemacht.test`)"
            - "traefik.http.routers.markemacht.entrypoints=websecure"
            - "traefik.http.routers.markemacht.tls=true"
            - "traefik.http.routers.markemacht.service=markemacht-service-prc"
            # Brand Rules Domain
            - "traefik.http.routers.brand-rules.rule=Host(`brand-rules.test`)"
            - "traefik.http.routers.brand-rules.entrypoints=websecure"
            - "traefik.http.routers.brand-rules.tls=true"
            - "traefik.http.routers.brand-rules.service=brand-rules-service-prc"


            # Asset-Domain für Vite-Dev-Server (Port 5178)
            - "traefik.http.routers.assets-brand.rule=Host(`assets.brand-rules.test`)"
            - "traefik.http.routers.assets-brand.entrypoints=websecure"
            - "traefik.http.routers.assets-brand.tls=true"
            - "traefik.http.routers.assets-brand.service=assets-brand-service-prc"

            # Service-Definitionen
            - "traefik.http.services.markemacht-service-prc.loadbalancer.server.port=80"
            - "traefik.http.services.brand-rules-service-prc.loadbalancer.server.port=80"
            - "traefik.http.services.assets-brand-service-prc.loadbalancer.server.port=5179"
            - "traefik.http.services.assets-brand-service-prc.loadbalancer.server.scheme=http"
            - "traefik.docker.network=proxy"

networks:
    sail:
        driver: bridge
    proxy:
        external: true
