services:
  mailhost:
    image: docker.io/greenmail/standalone
    environment:
      GREENMAIL_OPTS: '-Dgreenmail.setup.test.all -Dgreenmail.hostname=0.0.0.0 -Dgreenmail.auth.disabled -Dgreenmail.preload.dir=/emails'
    volumes:
      - "../tests/MessageRendering/data/greenmail:/emails"
  browserhost:
    image: docker.io/selenium/standalone-chromium
    ports:
      # Allow to watch the remote controlled browser (comment out the
      # `--headless` argument in TestCase::driver() before).
      # The password is 'secret'.
      - '127.0.0.1:7900:7900'
    volumes:
      - '/dev/shm:/dev/shm'
      - '../tests/Browser/downloads:/downloads'

  browser_tests:
    depends_on:
      - mailhost
      - browserhost
    hostname: 'testrunner'
    image: ${ROUNDCUBEMAIL_IMAGE_TESTRUNNER:-ghcr.io/roundcube/roundcubemail-testrunner:php8.3}
    volumes:
      - '..:/app'
      - '../tests/Browser/downloads:/downloads'
    environment:
      WEBDRIVER_CONNECT_URL: 'http://browserhost:4444'
      SERVER_URL: 'http://testrunner:8000'
      SERVER_BIND: '0.0.0.0:8000'
      BROWSER_DOWNLOADS_DIR: '/downloads'
      TESTRUNNER_DOWNLOADS_DIR: './tests/Browser/downloads'
      RC_CONFIG_IMAP_HOST: 'tls://mailhost:3143'
      RC_CONFIG_SMTP_HOST: 'mailhost:3025'
      COMPOSER_ARGS: ${COMPOSER_ARGS:-}
    working_dir: /work
    command: '/usr/local/bin/run-in-copy.sh .ci/run_browser_tests.sh'

  tests:
    depends_on:
      - mailhost
    image: ${ROUNDCUBEMAIL_IMAGE_TESTRUNNER:-ghcr.io/roundcube/roundcubemail-testrunner:php8.3}
    environment:
      COMPOSER_ARGS: ${COMPOSER_ARGS:-}
    volumes:
      - '..:/app'
    working_dir: /work
    command: '/usr/local/bin/run-in-copy.sh .ci/run_tests.sh'

  test_message_rendering:
    depends_on:
      - mailhost
    image: ${ROUNDCUBEMAIL_IMAGE_TESTRUNNER:-ghcr.io/roundcube/roundcubemail-testrunner:php8.3}
    environment:
      COMPOSER_ARGS: ${COMPOSER_ARGS:-}
      RC_CONFIG_IMAP_HOST: 'tls://mailhost:3143'
    volumes:
      - '..:/app'
    command:
      - .ci/run_test_message_rendering.sh

  codespell:
    image: ${ROUNDCUBEMAIL_IMAGE_TESTRUNNER:-ghcr.io/roundcube/roundcubemail-testrunner:php8.3}
    environment:
      COMPOSER_ARGS: ${COMPOSER_ARGS:-}
    volumes:
      - '..:/app'
    entrypoint: ./.ci/run_php-cs-fixer.sh

  codestyle:
    image: ${ROUNDCUBEMAIL_IMAGE_TESTRUNNER:-ghcr.io/roundcube/roundcubemail-testrunner:php8.3}
    environment:
      COMPOSER_ARGS: ${COMPOSER_ARGS:-}
    volumes:
      - '..:/app'
    entrypoint: ./.ci/run_phpstan.sh

  eslint:
    image: ghcr.io/roundcube/roundcubemail-testrunner:php8.3
    volumes:
      - '..:/app'
    entrypoint: ./.ci/run_eslint.sh
