version : '2.4'

services :
    redis :
        image : redis:alpine
        command : [ redis-server, --maxmemory 128mb, --maxmemory-policy volatile-lru, --save "" ]

    db :
        image : mysql:8.0.34
        container_name : pimcore-mysql
        ports :
            - "3001:3306"
        working_dir : /application
        command : --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
        volumes :
            - pimcore-database:/var/lib/mysql
        environment :
            - MYSQL_ROOT_PASSWORD=ROOT
            - MYSQL_DATABASE=pimcore
            - MYSQL_USER=pimcore
            - MYSQL_PASSWORD=pimcore
        healthcheck :
            test : [ "CMD-SHELL", "mysql -h db -u$$MYSQL_USER -p$$MYSQL_PASSWORD $$MYSQL_DATABASE -e 'SHOW TABLES;'" ]
            interval : 10s
            retries : 6
            start_period : 1m
            timeout : 3s

    nginx :
        image : nginx:stable-alpine
        ports :
            - "112:80"
        volumes :
            - .:/var/www/html:ro
            - ./.docker/nginx.conf:/etc/nginx/conf.d/default.conf:ro
        depends_on :
            - php

    php :
        build :
            context : .
            dockerfile : Dockerfile
        user : '501:20' # set to your uid:gid
        env_file : .env.local
        depends_on :
            - db
            - mercure
        volumes :
            - .:/var/www/html
            - ./.docker/20-pimcore.ini:/usr/local/etc/php/conf.d/20-pimcore.ini

    supervisord :
        build :
            context : .
            dockerfile : Dockerfilesupervisor
        user : '501:20'
        env_file : .env.local
        environment :
            RABBITMQ_DSN : amqp://guest:guest@rabbitmq:5672/%2f
        image : pimcore/pimcore:php8.2-supervisord-latest
        depends_on :
            - db
            - mercure
        volumes :
            - .:/var/www/html
            - ./.docker/supervisord.conf:/etc/supervisor/conf.d/pimcore.conf:ro

    rabbitmq :
        image : "rabbitmq:3-management-alpine"
        hostname : "rabbitmq"
        environment :
            RABBITMQ_DEFAULT_USER : "guest"
            RABBITMQ_DEFAULT_PASS : "guest"
        ports :
            - "15672:15672" # Management console
            - "5672:5672"   # RabbitMQ port
        labels :
            NAME : "rabbitmq"
        volumes :
            - "rabbitmq_data:/var/lib/rabbitmq"
        healthcheck :
            test : [ "CMD", "rabbitmqctl", "status" ]
            interval : 30s
            timeout : 30s
            retries : 3

    mercure :
        image : dunglas/mercure
        environment :
            DEBUG : "debug"
            SERVER_NAME : ':80'
            ALLOW_ANONYMOUS : 1
            MERCURE_PUBLISHER_JWT_KEY : 'chickenchickenchickenchickenchicken'
            MERCURE_SUBSCRIBER_JWT_KEY : 'chickenchickenchickenchickenchicken'
            CORS_ALLOWED_ORIGINS : "*"
            PUBLISH_ALLOWED_ORIGINS : "*"
            MERCURE_EXTRA_DIRECTIVES : |-
                cors_origins "*"
                anonymous

        ports :
            - "3332:80"

volumes :
    pimcore-database :
    rabbitmq_data :


