name: 'coreshop4.1'

x-php: &php
  volumes:
    - .:/var/www/html
    # Reset xdebug configuration to default
    - /dev/null:/usr/local/etc/php/conf.d/20-xdebug.ini:ro
  environment:
    PHP_IDE_CONFIG: serverName=localhost
    # Enable step debugging and development helpers by default.
    # `debug`-mode in conjuction with `trigger` (default) in `xdebug.start_with_request` enables step-debugging
    # only if a "trigger" (i.e. `XDEBUG_TRIGGER`) is present. Refer to
    # [start_with_request](https://xdebug.org/docs/all_settings#start_with_request) documentation of how to trigger
    # step debugging with `trigger`.
    # To configure PhpStorm for step-debugging with xdebug see: https://www.jetbrains.com/help/phpstorm/2021.3/zero-configuration-debugging.html#start-debugging-session
    # See: https://xdebug.org/docs/all_settings#mode
    XDEBUG_MODE: debug
    # This forces xdebug to always connect to the debug client running on docker host (host.docker.internal).
    # It will work without further configuration with [Docker Desktop](https://www.docker.com/products/docker-desktop).
    # See: https://xdebug.org/docs/all_settings#client_host
    XDEBUG_CONFIG: client_host=host.docker.internal
    COMPOSER_HOME: /var/www/html
    PIMCORE_DB_DSN: "mysql://pimcore:pimcore@db:3306/pimcore"
    PIMCORE_INSTALL_ADMIN_USERNAME: "admin"
    PIMCORE_INSTALL_ADMIN_PASSWORD: "admin"
    PIMCORE_INSTALL_MYSQL_HOST_SOCKET: "db"
    PIMCORE_INSTALL_MYSQL_USERNAME: "pimcore"
    PIMCORE_INSTALL_MYSQL_PASSWORD: "pimcore"
    PIMCORE_INSTALL_MYSQL_DATABASE: "pimcore"
    PIMCORE_INSTALL_MYSQL_PORT: "3306"
    PIMCORE_INSTALL_INSTALL_BUNDLES: "PimcoreApplicationLoggerBundle,PimcoreCustomReportsBundle,PimcoreGlossaryBundle,PimcoreSeoBundle,PimcoreSimpleBackendSearchBundle,PimcoreStaticRoutesBundle,PimcoreTinymceBundle,PimcoreUuidBundle,PimcoreWordExportBundle,PimcoreXliffBundle"
  extra_hosts:
    - "host.docker.internal:host-gateway"

services:
  db:
    container_name: coreshop4.1-db
    image: mariadb:10.5
    working_dir: /application
    command: [ mysqld, --character-set-server=utf8mb4, --collation-server=utf8mb4_general_ci ]
    volumes:
      - db:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=ROOT
      - MYSQL_DATABASE=pimcore
      - MYSQL_USER=pimcore
      - MYSQL_PASSWORD=pimcore
    expose:
      - "3306"

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

  php:
    <<: *php
    container_name: coreshop4.1-php
    image: coreshop/coreshop:PHP8.2-fpm-debug
    build:
      target: dev
      args:
        uid: ${USER_ID:-1000}
    depends_on:
      - db

  behat:
    <<: *php
    container_name: coreshop4.1-behat
    image: coreshop/coreshop:PHP8.2-fpm-debug-behat
    build:
      target: behat
      args:
        uid: ${USER_ID:-1000}
    entrypoint: docker-php-entrypoint
    profiles:
      - behat
    depends_on:
      - db
    environment:
      PIMCORE_TEST_DB_DSN: "mysql://root:ROOT@coreshop4.1-db/coreshop4_1___behat"
      PIMCORE_KERNEL_CLASS: 'Kernel'
    command:
      - bash
      - -c
      - |
        set -e;
        vendor/bin/bdi detect drivers;
        symfony server:start --port=9080 --dir=public --no-tls -d;
        CORESHOP_SKIP_DB_SETUP=1 PANTHER_EXTERNAL_BASE_URI=http://127.0.0.1:9080/index_test.php PANTHER_NO_HEADLESS=0 php -d memory_limit=-1 vendor/bin/behat -c behat.yml.dist -p ui

  gotenberg:
    image: gotenberg/gotenberg:8
    container_name: coreshop4.1-gotenberg

  chrome:
    image: browserless/chrome
    environment:
      - DEBUG=browserless:*
      - MAX_CONCURRENT_SESSIONS=10
      - CONNECTION_TIMEOUT=60000
      - MAX_QUEUE_LENGTH=20
      - PREBOOT_CHROME=true
      - DEMO_MODE=false
      - HOST=0.0.0.0
      - ENABLE_DEBUGGER=false
      - TOKEN=${BROWSERLESS_TOKEN}
      - PORT=3000
      - WORKSPACE_DELETE_EXPIRED=true
    container_name: coreshop4.1-chrome

volumes:
  db:
