name: octave_mozart

services:
    octave_mozart-php:
        build:
            context: ../../../infra/docker/php84-fpm
        volumes:
            - .:/var/www/html
            - ${PHP_INI-./config/php/php.ini}:/usr/local/etc/php/php.ini
            - ./.env.local:/var/www/html/.env.local:ro
            - ${HOME}/.ssh/id_rsa:/root/.ssh/id_rsa:ro
            - ${HOME}/.ssh/known_hosts:/root/.ssh/known_hosts:ro
        depends_on:
        - redis
        networks: [ octave_mozart-priv, mozart-network, sail]
        extra_hosts:
            - "host.docker.internal:host-gateway"
            - "www.mozartdigital.docker:host-gateway"
            - "api.mozartdigital.docker:host-gateway"
            - "www.monmarcheimmobilier.docker:host-gateway"
            - "octave.immo.docker:host-gateway"
        command: >
            sh -c "mkdir -p /var/www/html/storage && 
                   mkdir -p /var/www/html/bootstrap/cache && 
                   chmod -R 777 /var/www/html/storage && 
                   chmod -R 777 /var/www/html/bootstrap/cache && 
                   php-fpm"
    nginx:
        image: nginx:alpine
        depends_on: [ octave_mozart-php ]
        volumes:
            - .:/var/www/html
            - ./config/nginx/conf.d:/etc/nginx/conf.d
        networks: [ octave_mozart-priv, mozart-network ]
        expose:
            - "80"
        labels:
            - traefik.enable=true
            - traefik.http.routers.octave_mozart.rule=Host(`${SERVER_NAME}`) || Host(`www.${SERVER_NAME}`)
            - traefik.http.routers.octave_mozart.entrypoints=websecure
            - traefik.http.routers.octave_mozart.tls=true
            - traefik.http.services.octave_mozart.loadbalancer.server.port=80
            - traefik.docker.network=mozart-network
        extra_hosts:
            - "host.docker.internal:host-gateway"

networks:
    octave_mozart-priv:

    mozart-network:
        external: true


