services:
    php:
        image: ghcr.io/sylius/sylius-php:8.3-fixuid-xdebug-alpine
        user: ${DOCKER_USER:-1000:1000}
        depends_on:
            mysql:
                condition: service_healthy
        environment:
            # You can move these environment variables to your .env.local file
            APP_ENV: ${APP_ENV:-dev}
            APP_SECRET: EDITME
            DATABASE_URL: "mysql://root@mysql/sylius_%kernel.environment%"
            MAILER_DSN: smtp://mailhog:1025
            MESSENGER_TRANSPORT_DSN: doctrine://default
            SYLIUS_MESSENGER_TRANSPORT_MAIN_DSN: doctrine://default
            SYLIUS_MESSENGER_TRANSPORT_MAIN_FAILED_DSN: doctrine://default?queue_name=main_failed
            SYLIUS_MESSENGER_TRANSPORT_CATALOG_PROMOTION_REMOVAL_DSN: doctrine://default?queue_name=catalog_promotion_removal
            SYLIUS_MESSENGER_TRANSPORT_CATALOG_PROMOTION_REMOVAL_FAILED_DSN: doctrine://default?queue_name=catalog_promotion_removal_failed
            SYLIUS_MESSENGER_TRANSPORT_PAYMENT_REQUEST_DSN: sync://
            SYLIUS_MESSENGER_TRANSPORT_PAYMENT_REQUEST_FAILED_DSN: sync://
            PHP_DATE_TIMEZONE: ${PHP_DATE_TIMEZONE:-UTC}
            XDEBUG_MODE: debug
            XDEBUG_CONFIG: >-
                client_host=host.docker.internal
                client_port=9003
                log=/dev/stdout
            # This should correspond to the server declared in PHPStorm `Preferences | Languages & Frameworks | PHP | Servers`
            # Then PHPStorm will use the corresponding path mappings
            PHP_IDE_CONFIG: serverName=sylius
        extra_hosts:
            - "host.docker.internal:host-gateway"
        volumes:
          - .:/srv/sylius:rw,cached
          # if you develop on Linux, you may use a bind-mounted host directory instead
#          - ./var:/srv/sylius/var:rw
          - ./public:/srv/sylius/public:rw,delegated
          # if you develop on Linux, you may use a bind-mounted host directory instead
#          - ./public/media:/srv/sylius/public/media:rw
          - public-media:/srv/sylius/public/media:rw
    mysql:
        volumes:
            - mysql-data:/var/lib/mysql:rw
        ports:
            - "3306:3306"
    nginx:
        depends_on:
            php:
                condition: service_started
        volumes:
            - ./public:/srv/sylius/public:ro
            # if you develop on Linux, you may use a bind-mounted host directory instead
#            - ./public/media:/srv/sylius/public/media:ro
            - public-media:/srv/sylius/public/media:ro,nocopy
        ports:
            - "80:80"
    nodejs:
        image: node:${NODE_VERSION:-22}-alpine
        user: ${DOCKER_USER:-1000:1000}
        working_dir: /srv/sylius
        entrypoint: [ "/bin/sh","-c" ]
        command:
            - |
                yarn install
                yarn build
        volumes:
            - .:/srv/sylius:rw,cached
            - ./public:/srv/sylius/public:rw,delegated
    mailhog:
        ports:
            - "8025:8025"

volumes:
    mysql-data:
    public-media:
