version: '2.3'
services:
  chrome:
    image: selenium/standalone-chrome:3.12

  mysql55:
    image: mysql:5.5
    environment:
      MYSQL_ROOT_PASSWORD: funcp
    tmpfs:
      - /var/lib/mysql/:rw,noexec,nosuid

  mariadb10:
    image: mariadb:10.3
    environment:
      MYSQL_ROOT_PASSWORD: funcp
    tmpfs:
      - /var/lib/mysql/:rw,noexec,nosuid

  mssql2017cu17:
    image: mcr.microsoft.com/mssql/server:2017-CU17-ubuntu
    environment:
      ACCEPT_EULA: Y
      SA_PASSWORD: "Test1234!"
      MSSQL_PID: Developer
      MSSQL_MEMORY_LIMIT_MB: 3584
    tmpfs:
      - /var/lib/mssql:rw,noexec,nosuid

  mssql2017latest:
    image: mcr.microsoft.com/mssql/server:2017-latest-ubuntu
    environment:
      ACCEPT_EULA: Y
      SA_PASSWORD: "Test1234!"
      MSSQL_PID: Developer
      MSSQL_MEMORY_LIMIT_MB: 3584
    tmpfs:
      - /var/lib/mssql:rw,noexec,nosuid

  postgres10:
    image: postgres:10
    environment:
      POSTGRES_PASSWORD: funcp
      POSTGRES_USER: ${HOST_USER}
    tmpfs:
      - /var/lib/postgresql/data:rw,noexec,nosuid

  web:
    image: typo3gmbh/${DOCKER_PHP_IMAGE}:latest
    user: ${HOST_UID}
    stop_grace_period: 1s
    volumes:
      - ${CORE_ROOT}:${CORE_ROOT}
    command: php -n -c /etc/php/cli-no-xdebug/php.ini -S web:8000 -t ${CORE_ROOT}

  redis4:
    image: redis:4-alpine

  memcached1-5:
    image: memcached:1.5-alpine


  prepare_acceptance_backend_mariadb10:
    image: alpine:3.8
    links:
      - mariadb10
      - chrome
      - web
    command: >
      /bin/sh -c "
        if [ ${SCRIPT_VERBOSE} -eq 1 ]; then
          set -x
        fi
        echo Waiting for database start...;
        while ! nc -z mariadb10 3306; do
          sleep 1;
        done;
        echo Database is up;
      "
  acceptance_backend_mariadb10:
    image: typo3gmbh/${DOCKER_PHP_IMAGE}:latest
    user: ${HOST_UID}
    environment:
      typo3DatabaseName: func_test
      typo3DatabaseUsername: root
      typo3DatabasePassword: funcp
      typo3DatabaseHost: mariadb10
    volumes:
      - ${CORE_ROOT}:${CORE_ROOT}
      - ${HOST_HOME}:${HOST_HOME}
      - /etc/passwd:/etc/passwd:ro
      - /etc/group:/etc/group:ro
    working_dir: ${CORE_ROOT}
    command: >
      /bin/sh -c "
        if [ ${SCRIPT_VERBOSE} -eq 1 ]; then
          set -x
        fi
        mkdir -p typo3temp/var/tests/ \
          && ./bin/codecept run Backend -d -c typo3/sysext/core/Tests/codeception.yml ${TEST_FILE} --html reports.html
      "

  prepare_acceptance_pagetree_mariadb10:
    image: alpine:3.8
    links:
      - mariadb10
      - chrome
      - web
    command: >
      /bin/sh -c "
        if [ ${SCRIPT_VERBOSE} -eq 1 ]; then
          set -x
        fi
        echo Waiting for database start...;
        while ! nc -z mariadb10 3306; do
          sleep 1;
        done;
        echo Database is up;
      "
  acceptance_pagetree_mariadb10:
    image: typo3gmbh/${DOCKER_PHP_IMAGE}:latest
    user: ${HOST_UID}
    environment:
      typo3DatabaseName: func_test
      typo3DatabaseUsername: root
      typo3DatabasePassword: funcp
      typo3DatabaseHost: mariadb10
    volumes:
      - ${CORE_ROOT}:${CORE_ROOT}
      - ${HOST_HOME}:${HOST_HOME}
      - /etc/passwd:/etc/passwd:ro
      - /etc/group:/etc/group:ro
    working_dir: ${CORE_ROOT}
    command: >
      /bin/sh -c "
        if [ ${SCRIPT_VERBOSE} -eq 1 ]; then
          set -x
        fi
        mkdir -p typo3temp/var/tests/ \
          && ./bin/codecept run PageTree -d -c typo3/sysext/core/Tests/codeception.yml ${TEST_FILE} --html reports.html
      "

  prepare_acceptance_install_mariadb10:
    image: alpine:3.8
    links:
      - mariadb10
      - chrome
      - web
    command: >
      /bin/sh -c "
        if [ ${SCRIPT_VERBOSE} -eq 1 ]; then
          set -x
        fi
        echo Waiting for database start...;
        while ! nc -z mariadb10 3306; do
          sleep 1;
        done;
        echo Database is up;
      "
  acceptance_install_mariadb10:
    image: typo3gmbh/${DOCKER_PHP_IMAGE}:latest
    user: ${HOST_UID}
    environment:
      typo3InstallMysqlDatabaseHost: mariadb10
      typo3InstallMysqlDatabaseName: func_test
      typo3InstallMysqlDatabaseUsername: root
      typo3InstallMysqlDatabasePassword: funcp
    volumes:
      - ${CORE_ROOT}:${CORE_ROOT}
      - ${HOST_HOME}:${HOST_HOME}
      - /etc/passwd:/etc/passwd:ro
      - /etc/group:/etc/group:ro
    working_dir: ${CORE_ROOT}
    command: >
      /bin/sh -c "
        if [ ${SCRIPT_VERBOSE} -eq 1 ]; then
          set -x
        fi
        mkdir -p typo3temp/var/tests/ \
          && ./bin/codecept run Install -d -c typo3/sysext/core/Tests/codeception.yml --env=mysql --html reports.html
      "

  prepare_acceptance_install_postgres10:
    image: alpine:3.8
    links:
      - postgres10
      - chrome
      - web
    command: >
      /bin/sh -c "
        if [ ${SCRIPT_VERBOSE} -eq 1 ]; then
          set -x
        fi
        echo Waiting for database start...;
        while ! nc -z postgres10 5432; do
          sleep 1;
        done;
        echo Database is up;
      "
  acceptance_install_postgres10:
    image: typo3gmbh/${DOCKER_PHP_IMAGE}:latest
    user: ${HOST_UID}
    environment:
      typo3InstallPostgresqlDatabaseHost: postgres10
      typo3InstallPostgresqlDatabaseName: ${HOST_USER}
      typo3InstallPostgresqlDatabaseUsername: ${HOST_USER}
      typo3InstallPostgresqlDatabasePassword: funcp
    working_dir: ${CORE_ROOT}
    volumes:
      - ${CORE_ROOT}:${CORE_ROOT}
      - ${HOST_HOME}:${HOST_HOME}
      - /etc/passwd:/etc/passwd:ro
      - /etc/group:/etc/group:ro
    command: >
      /bin/sh -c "
        if [ ${SCRIPT_VERBOSE} -eq 1 ]; then
          set -x
        fi
        mkdir -p typo3temp/var/tests/ \
          && ./bin/codecept run Install -d -c typo3/sysext/core/Tests/codeception.yml --env=postgresql --html reports.html
      "

  prepare_acceptance_install_sqlite:
    image: alpine:3.8
    links:
      - chrome
      - web
    command: >
      /bin/sh -c "
        sleep 1;
      "
  acceptance_install_sqlite:
    image: typo3gmbh/${DOCKER_PHP_IMAGE}:latest
    user: ${HOST_UID}
    volumes:
      - ${CORE_ROOT}:${CORE_ROOT}
      - ${HOST_HOME}:${HOST_HOME}
      - /etc/passwd:/etc/passwd:ro
      - /etc/group:/etc/group:ro
    working_dir: ${CORE_ROOT}
    command: >
      /bin/sh -c "
        if [ ${SCRIPT_VERBOSE} -eq 1 ]; then
          set -x
        fi
        mkdir -p typo3temp/var/tests/ \
          && ./bin/codecept run Install -d -c typo3/sysext/core/Tests/codeception.yml --env=sqlite --html reports.html
      "

  build_css:
    image: typo3gmbh/${DOCKER_JS_IMAGE}:latest
    user: ${HOST_UID}
    volumes:
    - ${CORE_ROOT}:${CORE_ROOT}
    - ${HOST_HOME}:${HOST_HOME}
    - /etc/passwd:/etc/passwd:ro
    - /etc/group:/etc/group:ro
    working_dir: ${CORE_ROOT}/Build
    command: >
      /bin/sh -c "
        if [ ${SCRIPT_VERBOSE} -eq 1 ]; then
          set -x
        fi
        yarn install \
          && ./node_modules/grunt/bin/grunt css
      "

  build_javascript:
    image: typo3gmbh/${DOCKER_JS_IMAGE}:latest
    user: ${HOST_UID}
    volumes:
    - ${CORE_ROOT}:${CORE_ROOT}
    - ${HOST_HOME}:${HOST_HOME}
    - /etc/passwd:/etc/passwd:ro
    - /etc/group:/etc/group:ro
    working_dir: ${CORE_ROOT}/Build
    command: >
      /bin/sh -c "
        if [ ${SCRIPT_VERBOSE} -eq 1 ]; then
          set -x
        fi
        yarn install \
          && ./node_modules/grunt/bin/grunt scripts
      "

  cgl_git:
    image: typo3gmbh/${DOCKER_PHP_IMAGE}:latest
    user: ${HOST_UID}
    volumes:
    - ${CORE_ROOT}:${CORE_ROOT}
    - ${HOST_HOME}:${HOST_HOME}
    - /etc/passwd:/etc/passwd:ro
    - /etc/group:/etc/group:ro
    working_dir: ${CORE_ROOT}
    command: >
      /bin/sh -c "
        if [ ${SCRIPT_VERBOSE} -eq 1 ]; then
          set -x
        fi
        Build/Scripts/cglFixMyCommit.sh ${CGLCHECK_DRY_RUN};
      "

  cgl_all:
    image: typo3gmbh/${DOCKER_PHP_IMAGE}:latest
    user: ${HOST_UID}
    volumes:
    - ${CORE_ROOT}:${CORE_ROOT}
    - ${HOST_HOME}:${HOST_HOME}
    - /etc/passwd:/etc/passwd:ro
    - /etc/group:/etc/group:ro
    working_dir: ${CORE_ROOT}
    command: >
      /bin/sh -c "
        if [ ${SCRIPT_VERBOSE} -eq 1 ]; then
          set -x
        fi
        php -n -c /etc/php/cli-no-xdebug/php.ini bin/php-cs-fixer fix -v ${CGLCHECK_DRY_RUN} --path-mode intersection \
          --config=Build/.php_cs typo3/
      "

  check_annotations:
    image: typo3gmbh/${DOCKER_PHP_IMAGE}:latest
    user: ${HOST_UID}
    volumes:
    - ${CORE_ROOT}:${CORE_ROOT}
    - ${HOST_HOME}:${HOST_HOME}
    - /etc/passwd:/etc/passwd:ro
    - /etc/group:/etc/group:ro
    working_dir: ${CORE_ROOT}
    command: >
      /bin/sh -c "
        if [ ${SCRIPT_VERBOSE} -eq 1 ]; then
          set -x
        fi
        Build/Scripts/annotationChecker.php;
      "

  check_bom:
    image: typo3gmbh/${DOCKER_PHP_IMAGE}:latest
    user: ${HOST_UID}
    volumes:
    - ${CORE_ROOT}:${CORE_ROOT}
    - ${HOST_HOME}:${HOST_HOME}
    - /etc/passwd:/etc/passwd:ro
    - /etc/group:/etc/group:ro
    working_dir: ${CORE_ROOT}
    command: >
      /bin/sh -c "
        if [ ${SCRIPT_VERBOSE} -eq 1 ]; then
          set -x
        fi
        Build/Scripts/checkUtf8Bom.sh
      "

  check_composer:
    image: typo3gmbh/${DOCKER_PHP_IMAGE}:latest
    user: ${HOST_UID}
    volumes:
    - ${CORE_ROOT}:${CORE_ROOT}
    - ${HOST_HOME}:${HOST_HOME}
    - /etc/passwd:/etc/passwd:ro
    - /etc/group:/etc/group:ro
    working_dir: ${CORE_ROOT}
    command: >
      /bin/sh -c "
        if [ ${SCRIPT_VERBOSE} -eq 1 ]; then
          set -x
        fi
        Build/Scripts/checkIntegrityComposer.php;
      "

  check_csv_fixtures:
    image: typo3gmbh/${DOCKER_PHP_IMAGE}:latest
    user: ${HOST_UID}
    volumes:
    - ${CORE_ROOT}:${CORE_ROOT}
    - ${HOST_HOME}:${HOST_HOME}
    - /etc/passwd:/etc/passwd:ro
    - /etc/group:/etc/group:ro
    working_dir: ${CORE_ROOT}
    command: >
      /bin/sh -c "
        if [ ${SCRIPT_VERBOSE} -eq 1 ]; then
          set -x
        fi
        Build/Scripts/checkIntegrityCsvFixtures.php;
      "

  check_exception_codes:
    image: typo3gmbh/${DOCKER_PHP_IMAGE}:latest
    user: ${HOST_UID}
    volumes:
    - ${CORE_ROOT}:${CORE_ROOT}
    - ${HOST_HOME}:${HOST_HOME}
    - /etc/passwd:/etc/passwd:ro
    - /etc/group:/etc/group:ro
    working_dir: ${CORE_ROOT}
    command: >
      /bin/sh -c "
        if [ ${SCRIPT_VERBOSE} -eq 1 ]; then
          set -x
        fi
        Build/Scripts/duplicateExceptionCodeCheck.sh;
      "

  check_extension_scanner_rst:
    image: typo3gmbh/${DOCKER_PHP_IMAGE}:latest
    user: ${HOST_UID}
    volumes:
    - ${CORE_ROOT}:${CORE_ROOT}
    - ${HOST_HOME}:${HOST_HOME}
    - /etc/passwd:/etc/passwd:ro
    - /etc/group:/etc/group:ro
    working_dir: ${CORE_ROOT}
    command: >
      /bin/sh -c "
        if [ ${SCRIPT_VERBOSE} -eq 1 ]; then
          set -x
        fi
        Build/Scripts/extensionScannerRstFileReferences.php;
      "

  check_file_path_length:
    image: typo3gmbh/${DOCKER_PHP_IMAGE}:latest
    user: ${HOST_UID}
    volumes:
    - ${CORE_ROOT}:${CORE_ROOT}
    - ${HOST_HOME}:${HOST_HOME}
    - /etc/passwd:/etc/passwd:ro
    - /etc/group:/etc/group:ro
    working_dir: ${CORE_ROOT}
    command: >
      /bin/sh -c "
        if [ ${SCRIPT_VERBOSE} -eq 1 ]; then
          set -x
        fi
        Build/Scripts/maxFilePathLength.sh;
      "

  check_git_submodule:
    image: typo3gmbh/${DOCKER_PHP_IMAGE}:latest
    user: ${HOST_UID}
    volumes:
    - ${CORE_ROOT}:${CORE_ROOT}
    - ${HOST_HOME}:${HOST_HOME}
    - /etc/passwd:/etc/passwd:ro
    - /etc/group:/etc/group:ro
    working_dir: ${CORE_ROOT}
    command: >
      /bin/sh -c "
        if [ ${SCRIPT_VERBOSE} -eq 1 ]; then
          set -x
        fi
        if [ `git submodule status 2>&1 | wc -l` -ne 0 ]; then
          echo \"Found a submodule definition in repository\";
          exit 1;
        fi
      "

  check_permissions:
    image: typo3gmbh/${DOCKER_PHP_IMAGE}:latest
    user: ${HOST_UID}
    volumes:
    - ${CORE_ROOT}:${CORE_ROOT}
    - ${HOST_HOME}:${HOST_HOME}
    - /etc/passwd:/etc/passwd:ro
    - /etc/group:/etc/group:ro
    working_dir: ${CORE_ROOT}
    command: >
      /bin/sh -c "
        if [ ${SCRIPT_VERBOSE} -eq 1 ]; then
          set -x
        fi
        Build/Scripts/checkFilePermissions.sh;
      "

  check_rst:
    image: typo3gmbh/${DOCKER_PHP_IMAGE}:latest
    user: ${HOST_UID}
    volumes:
    - ${CORE_ROOT}:${CORE_ROOT}
    - ${HOST_HOME}:${HOST_HOME}
    - /etc/passwd:/etc/passwd:ro
    - /etc/group:/etc/group:ro
    working_dir: ${CORE_ROOT}
    command: >
      /bin/sh -c "
        if [ ${SCRIPT_VERBOSE} -eq 1 ]; then
          set -x
        fi
        Build/Scripts/validateRstFiles.php;
      "

  check_xlf:
    image: typo3gmbh/${DOCKER_PHP_IMAGE}:latest
    user: ${HOST_UID}
    volumes:
    - ${CORE_ROOT}:${CORE_ROOT}
    - ${HOST_HOME}:${HOST_HOME}
    - /etc/passwd:/etc/passwd:ro
    - /etc/group:/etc/group:ro
    working_dir: ${CORE_ROOT}
    command: >
      /bin/sh -c "
        if [ ${SCRIPT_VERBOSE} -eq 1 ]; then
          set -x
        fi
        Build/Scripts/xlfcheck.sh;
      "

  composer_install:
    image: typo3gmbh/${DOCKER_PHP_IMAGE}:latest
    user: ${HOST_UID}
    volumes:
    - ${CORE_ROOT}:${CORE_ROOT}
    - ${HOST_HOME}:${HOST_HOME}
    - /etc/passwd:/etc/passwd:ro
    - /etc/group:/etc/group:ro
    working_dir: ${CORE_ROOT}
    command: >
      /bin/sh -c "
        if [ ${SCRIPT_VERBOSE} -eq 1 ]; then
          set -x
        fi
        composer install;
      "

  composer_validate:
    image: typo3gmbh/${DOCKER_PHP_IMAGE}:latest
    user: ${HOST_UID}
    volumes:
    - ${CORE_ROOT}:${CORE_ROOT}
    - ${HOST_HOME}:${HOST_HOME}
    - /etc/passwd:/etc/passwd:ro
    - /etc/group:/etc/group:ro
    working_dir: ${CORE_ROOT}
    command: >
      /bin/sh -c "
        if [ ${SCRIPT_VERBOSE} -eq 1 ]; then
          set -x
        fi
        composer validate;
      "

  prepare_functional_mariadb10:
    image: alpine:3.8
    links:
      - mariadb10
      - redis4
      - memcached1-5
    command: >
      /bin/sh -c "
        if [ ${SCRIPT_VERBOSE} -eq 1 ]; then
          set -x
        fi
        echo Waiting for database start...;
        while ! nc -z mariadb10 3306; do
          sleep 1;
        done;
        echo Database is up;
      "
  functional_mariadb10:
    image: typo3gmbh/${DOCKER_PHP_IMAGE}:latest
    user: ${HOST_UID}
    volumes:
      - ${CORE_ROOT}:${CORE_ROOT}
      - ${HOST_HOME}:${HOST_HOME}
      - /etc/passwd:/etc/passwd:ro
      - /etc/group:/etc/group:ro
    environment:
      typo3DatabaseDriver: "${DATABASE_DRIVER:-mysqli}"
      typo3DatabaseName: func_test
      typo3DatabaseUsername: root
      typo3DatabasePassword: funcp
      typo3DatabaseHost: mariadb10
      typo3TestingRedisHost: redis4
      typo3TestingMemcachedHost: memcached1-5
    working_dir: ${CORE_ROOT}
    command: >
      /bin/sh -c "
        if [ ${SCRIPT_VERBOSE} -eq 1 ]; then
          set -x
        fi
        php -v | grep '^PHP'
        if [ ${PHP_XDEBUG_ON} -eq 0 ]; then
          php -n -c /etc/php/cli-no-xdebug/php.ini \
            vendor/phpunit/phpunit/phpunit -c vendor/typo3/testing-framework/Resources/Core/Build/FunctionalTests.xml \
            -c vendor/typo3/testing-framework/Resources/Core/Build/Failing.xml \
            ${EXTRA_TEST_OPTIONS} ${TEST_FILE};
        else
          DOCKER_HOST=`route -n | awk '/^0.0.0.0/ { print $$2 }'`
          XDEBUG_CONFIG=\"remote_port=${PHP_XDEBUG_PORT} remote_enable=1 remote_host=$${DOCKER_HOST}\" \
            vendor/phpunit/phpunit/phpunit -c vendor/typo3/testing-framework/Resources/Core/Build/FunctionalTests.xml ${EXTRA_TEST_OPTIONS} ${TEST_FILE};
        fi
      "

  prepare_functional_mysql55:
    image: alpine:3.8
    links:
      - mysql55
      - redis4
      - memcached1-5
    command: >
      /bin/sh -c "
        if [ ${SCRIPT_VERBOSE} -eq 1 ]; then
          set -x
        fi
        echo Waiting for database start...;
        while ! nc -z mysql55 3306; do
          sleep 1;
        done;
        echo Database is up;
      "
  functional_mysql55:
    image: typo3gmbh/${DOCKER_PHP_IMAGE}:latest
    user: ${HOST_UID}
    volumes:
      - ${CORE_ROOT}:${CORE_ROOT}
      - ${HOST_HOME}:${HOST_HOME}
      - /etc/passwd:/etc/passwd:ro
      - /etc/group:/etc/group:ro
    environment:
      typo3DatabaseDriver: "${DATABASE_DRIVER:-mysqli}"
      typo3DatabaseName: func_test
      typo3DatabaseUsername: root
      typo3DatabasePassword: funcp
      typo3DatabaseHost: mysql55
      typo3TestingRedisHost: redis4
      typo3TestingMemcachedHost: memcached1-5
    working_dir: ${CORE_ROOT}
    command: >
      /bin/sh -c "
        if [ ${SCRIPT_VERBOSE} -eq 1 ]; then
          set -x
        fi
        php -v | grep '^PHP'
        if [ ${PHP_XDEBUG_ON} -eq 0 ]; then
          php -n -c /etc/php/cli-no-xdebug/php.ini \
            vendor/phpunit/phpunit/phpunit -c vendor/typo3/testing-framework/Resources/Core/Build/FunctionalTests.xml \
            -c vendor/typo3/testing-framework/Resources/Core/Build/FunctionalTests-Job-5.xml \
            ${EXTRA_TEST_OPTIONS} ${TEST_FILE};
        else
          DOCKER_HOST=`route -n | awk '/^0.0.0.0/ { print $$2 }'`
          XDEBUG_CONFIG=\"remote_port=${PHP_XDEBUG_PORT} remote_enable=1 remote_host=$${DOCKER_HOST}\" \
            vendor/phpunit/phpunit/phpunit -c vendor/typo3/testing-framework/Resources/Core/Build/FunctionalTests.xml ${EXTRA_TEST_OPTIONS} ${TEST_FILE};
        fi
      "

  prepare_functional_mssql2017cu17:
    image: alpine:3.8
    links:
      - mssql2017cu17
      - redis4
      - memcached1-5
    command: >
      /bin/sh -c "
        if [ ${SCRIPT_VERBOSE} -eq 1 ]; then
          set -x
        fi
        echo Waiting for database start...;
        while ! nc -z mssql2017cu17 1433; do
          sleep 1;
        done;
        echo Database is up;
      "
  functional_mssql2017cu17:
    image: typo3gmbh/${DOCKER_PHP_IMAGE}:latest
    user: ${HOST_UID}
    volumes:
      - ${CORE_ROOT}:${CORE_ROOT}
      - ${HOST_HOME}:${HOST_HOME}
      - /etc/passwd:/etc/passwd:ro
      - /etc/group:/etc/group:ro
    environment:
      typo3DatabaseDriver: "${DATABASE_DRIVER:-sqlsrv}"
      typo3DatabaseName: func
      typo3DatabasePassword: "Test1234!"
      typo3DatabaseUsername: SA
      typo3DatabasePort: 1433
      typo3DatabaseCharset: utf-8
      typo3DatabaseHost: mssql2017cu17
      typo3TestingRedisHost: redis4
      typo3TestingMemcachedHost: memcached1-5
    working_dir: ${CORE_ROOT}
    command: >
      /bin/sh -c "
        if [ ${SCRIPT_VERBOSE} -eq 1 ]; then
          set -x
        fi
        php -v | grep '^PHP'
        if [ ${PHP_XDEBUG_ON} -eq 0 ]; then
          php -n -c /etc/php/cli-no-xdebug/php.ini \
            vendor/phpunit/phpunit/phpunit -c vendor/typo3/testing-framework/Resources/Core/Build/FunctionalTests.xml ${EXTRA_TEST_OPTIONS} --exclude-group not-mssql ${TEST_FILE};
        else
          DOCKER_HOST=`route -n | awk '/^0.0.0.0/ { print $$2 }'`
          XDEBUG_CONFIG=\"remote_port=${PHP_XDEBUG_PORT} remote_enable=1 remote_host=$${DOCKER_HOST}\" \
            vendor/phpunit/phpunit/phpunit -c vendor/typo3/testing-framework/Resources/Core/Build/FunctionalTests.xml ${EXTRA_TEST_OPTIONS} --exclude-group not-mssql ${TEST_FILE};
        fi
      "

  prepare_functional_mssql2017latest:
    image: alpine:3.8
    links:
      - mssql2017latest
      - redis4
      - memcached1-5
    command: >
      /bin/sh -c "
        if [ ${SCRIPT_VERBOSE} -eq 1 ]; then
          set -x
        fi
        echo Waiting for database start...;
        while ! nc -z mssql2017latest 1433; do
          sleep 1;
        done;
        echo Database is up;
      "

  functional_mssql2017latest:
    image: typo3gmbh/${DOCKER_PHP_IMAGE}:latest
    user: ${HOST_UID}
    volumes:
      - ${CORE_ROOT}:${CORE_ROOT}
      - ${HOST_HOME}:${HOST_HOME}
      - /etc/passwd:/etc/passwd:ro
      - /etc/group:/etc/group:ro
    environment:
      typo3DatabaseDriver: "${DATABASE_DRIVER:-sqlsrv}"
      typo3DatabaseName: func
      typo3DatabasePassword: "Test1234!"
      typo3DatabaseUsername: SA
      typo3DatabasePort: 1433
      typo3DatabaseCharset: utf-8
      typo3DatabaseHost: mssql2017latest
      typo3TestingRedisHost: redis4
      typo3TestingMemcachedHost: memcached1-5
    working_dir: ${CORE_ROOT}
    command: >
      /bin/sh -c "
        if [ ${SCRIPT_VERBOSE} -eq 1 ]; then
          set -x
        fi
        php -v | grep '^PHP'
        if [ ${PHP_XDEBUG_ON} -eq 0 ]; then
          php -n -c /etc/php/cli-no-xdebug/php.ini \
            vendor/phpunit/phpunit/phpunit -c vendor/typo3/testing-framework/Resources/Core/Build/FunctionalTests.xml ${EXTRA_TEST_OPTIONS} --exclude-group not-mssql ${TEST_FILE};
        else
          DOCKER_HOST=`route -n | awk '/^0.0.0.0/ { print $$2 }'`
          XDEBUG_CONFIG=\"remote_port=${PHP_XDEBUG_PORT} remote_enable=1 remote_host=$${DOCKER_HOST}\" \
            vendor/phpunit/phpunit/phpunit -c vendor/typo3/testing-framework/Resources/Core/Build/FunctionalTests.xml ${EXTRA_TEST_OPTIONS} --exclude-group not-mssql ${TEST_FILE};
        fi
      "

  prepare_functional_postgres10:
    image: alpine:3.8
    links:
      - postgres10
      - redis4
      - memcached1-5
    command: >
      /bin/sh -c "
        if [ ${SCRIPT_VERBOSE} -eq 1 ]; then
          set -x
        fi
        echo Waiting for database start...;
        while ! nc -z postgres10 5432; do
          sleep 1;
        done;
        echo Database is up;
      "
  functional_postgres10:
    image: typo3gmbh/${DOCKER_PHP_IMAGE}:latest
    user: ${HOST_UID}
    volumes:
      - ${CORE_ROOT}:${CORE_ROOT}
      - ${HOST_HOME}:${HOST_HOME}
      - /etc/passwd:/etc/passwd:ro
      - /etc/group:/etc/group:ro
    environment:
      typo3DatabaseDriver: pdo_pgsql
      typo3DatabaseName: bamboo
      typo3DatabaseUsername: ${HOST_USER}
      typo3DatabaseHost: postgres10
      typo3DatabasePassword: funcp
      typo3TestingRedisHost: redis4
      typo3TestingMemcachedHost: memcached1-5
    working_dir: ${CORE_ROOT}
    command: >
      /bin/sh -c "
        if [ ${SCRIPT_VERBOSE} -eq 1 ]; then
          set -x
        fi
        php -v | grep '^PHP'
        if [ ${PHP_XDEBUG_ON} -eq 0 ]; then
          php -n -c /etc/php/cli-no-xdebug/php.ini \
            vendor/phpunit/phpunit/phpunit -c vendor/typo3/testing-framework/Resources/Core/Build/FunctionalTests.xml ${EXTRA_TEST_OPTIONS} --exclude-group not-postgres ${TEST_FILE};
        else
          DOCKER_HOST=`route -n | awk '/^0.0.0.0/ { print $$2 }'`
          XDEBUG_CONFIG=\"remote_port=${PHP_XDEBUG_PORT} remote_enable=1 remote_host=$${DOCKER_HOST}\" \
            vendor/phpunit/phpunit/phpunit -c vendor/typo3/testing-framework/Resources/Core/Build/FunctionalTests.xml ${EXTRA_TEST_OPTIONS} --exclude-group not-postgres ${TEST_FILE};
        fi
      "

  prepare_functional_sqlite:
    image: alpine:3.8
    links:
      - redis4
      - memcached1-5
    command: >
      /bin/sh -c "
        sleep 1;
      "
  functional_sqlite:
    image: typo3gmbh/${DOCKER_PHP_IMAGE}:latest
    user: ${HOST_UID}
    volumes:
      - ${CORE_ROOT}:${CORE_ROOT}
      - ${HOST_HOME}:${HOST_HOME}
      - /etc/passwd:/etc/passwd:ro
      - /etc/group:/etc/group:ro
      # @todo: sqlite DB is currently written to functional-doc-root (typo3temp/var/test-functional-xy/) /test.sqlite
      # This directory is mapped to the local dir, so it is hard disk and not a tmpfs. sqlite functionals would speed
      # up significantly if typo3/testing-framework would accept an environment variable to locate test.sqlite file on
      # some tmpfs mount. Note this is not an issue within bamboo since in bamboo the entire core checkout is a tmpfs already.
    environment:
      typo3DatabaseDriver: pdo_sqlite
      typo3TestingRedisHost: redis4
      typo3TestingMemcachedHost: memcached1-5
    working_dir: ${CORE_ROOT}
    command: >
      /bin/sh -c "
        if [ ${SCRIPT_VERBOSE} -eq 1 ]; then
          set -x
        fi
        php -v | grep '^PHP'
        if [ ${PHP_XDEBUG_ON} -eq 0 ]; then
          php -n -c /etc/php/cli-no-xdebug/php.ini \
            vendor/phpunit/phpunit/phpunit -c vendor/typo3/testing-framework/Resources/Core/Build/FunctionalTests.xml ${EXTRA_TEST_OPTIONS} --exclude-group not-sqlite ${TEST_FILE};
        else
          DOCKER_HOST=`route -n | awk '/^0.0.0.0/ { print $$2 }'`
          XDEBUG_CONFIG=\"remote_port=${PHP_XDEBUG_PORT} remote_enable=1 remote_host=$${DOCKER_HOST}\" \
            vendor/phpunit/phpunit/phpunit -c vendor/typo3/testing-framework/Resources/Core/Build/FunctionalTests.xml ${EXTRA_TEST_OPTIONS} --exclude-group not-sqlite ${TEST_FILE};
        fi
      "

  lint:
    image: typo3gmbh/${DOCKER_PHP_IMAGE}:latest
    user: ${HOST_UID}
    volumes:
    - ${CORE_ROOT}:${CORE_ROOT}
    - /etc/passwd:/etc/passwd:ro
    - /etc/group:/etc/group:ro
    working_dir: ${CORE_ROOT}
    command: >
      /bin/sh -c "
        if [ ${SCRIPT_VERBOSE} -eq 1 ]; then
          set -x
        fi
        php -v | grep '^PHP'
        find typo3/ -name \\*.php -print0 | xargs -0 -n1 -P4 php -n -c /etc/php/cli-no-xdebug/php.ini -l >/dev/null
      "

  lint_scss:
    image: typo3gmbh/${DOCKER_JS_IMAGE}:latest
    user: ${HOST_UID}
    volumes:
    - ${CORE_ROOT}:${CORE_ROOT}
    - ${HOST_HOME}:${HOST_HOME}
    - /etc/passwd:/etc/passwd:ro
    - /etc/group:/etc/group:ro
    working_dir: ${CORE_ROOT}/Build
    command: >
      /bin/sh -c "
        if [ ${SCRIPT_VERBOSE} -eq 1 ]; then
          set -x
        fi
        yarn install \
          && ./node_modules/grunt/bin/grunt stylelint;
      "

  lint_typescript:
    image: typo3gmbh/${DOCKER_JS_IMAGE}:latest
    user: ${HOST_UID}
    volumes:
    - ${CORE_ROOT}:${CORE_ROOT}
    - ${HOST_HOME}:${HOST_HOME}
    - /etc/passwd:/etc/passwd:ro
    - /etc/group:/etc/group:ro
    working_dir: ${CORE_ROOT}/Build
    command: >
      /bin/sh -c "
        if [ ${SCRIPT_VERBOSE} -eq 1 ]; then
          set -x
        fi
        yarn install \
          && ./node_modules/grunt/bin/grunt tslint;
      "

  unit:
    image: typo3gmbh/${DOCKER_PHP_IMAGE}:latest
    user: ${HOST_UID}
    volumes:
      - ${CORE_ROOT}:${CORE_ROOT}
      - ${HOST_HOME}:${HOST_HOME}
      - /etc/passwd:/etc/passwd:ro
      - /etc/group:/etc/group:ro
    working_dir: ${CORE_ROOT}
    command: >
      /bin/sh -c "
        if [ ${SCRIPT_VERBOSE} -eq 1 ]; then
          set -x
        fi
        php -v | grep '^PHP'
        if [ ${PHP_XDEBUG_ON} -eq 0 ]; then
          php -n -c /etc/php/cli-no-xdebug/php.ini \
            vendor/phpunit/phpunit/phpunit -c vendor/typo3/testing-framework/Resources/Core/Build/UnitTests.xml ${EXTRA_TEST_OPTIONS} ${TEST_FILE};
        else
          DOCKER_HOST=`route -n | awk '/^0.0.0.0/ { print $$2 }'`
          XDEBUG_CONFIG=\"remote_port=${PHP_XDEBUG_PORT} remote_enable=1 remote_host=$${DOCKER_HOST}\" \
            vendor/phpunit/phpunit/phpunit -c vendor/typo3/testing-framework/Resources/Core/Build/UnitTests.xml ${EXTRA_TEST_OPTIONS} ${TEST_FILE};
        fi
      "

  unitDeprecated:
    image: typo3gmbh/${DOCKER_PHP_IMAGE}:latest
    user: ${HOST_UID}
    volumes:
      - ${CORE_ROOT}:${CORE_ROOT}
      - ${HOST_HOME}:${HOST_HOME}
      - /etc/passwd:/etc/passwd:ro
      - /etc/group:/etc/group:ro
    working_dir: ${CORE_ROOT}
    command: >
      /bin/sh -c "
        if [ ${SCRIPT_VERBOSE} -eq 1 ]; then
          set -x
        fi
        php -v | grep '^PHP'
        if [ ${PHP_XDEBUG_ON} -eq 0 ]; then
          php -n -c /etc/php/cli-no-xdebug/php.ini \
            vendor/phpunit/phpunit/phpunit -c vendor/typo3/testing-framework/Resources/Core/Build/UnitTestsDeprecated.xml ${EXTRA_TEST_OPTIONS} ${TEST_FILE};
        else
          DOCKER_HOST=`route -n | awk '/^0.0.0.0/ { print $$2 }'`
          XDEBUG_CONFIG=\"remote_port=${PHP_XDEBUG_PORT} remote_enable=1 remote_host=$${DOCKER_HOST}\" \
            vendor/phpunit/phpunit/phpunit -c vendor/typo3/testing-framework/Resources/Core/Build/UnitTestsDeprecated.xml ${EXTRA_TEST_OPTIONS} ${TEST_FILE};
        fi
      "

  unitJavascript:
    image: typo3gmbh/${DOCKER_JS_IMAGE}:latest
    user: ${HOST_UID}
    volumes:
      - ${CORE_ROOT}:${CORE_ROOT}
      - ${HOST_HOME}:${HOST_HOME}
      - /etc/passwd:/etc/passwd:ro
      - /etc/group:/etc/group:ro
    working_dir: ${CORE_ROOT}/Build
    command: >
      /bin/sh -c "
        if [ ${SCRIPT_VERBOSE} -eq 1 ]; then
          set -x
        fi
        yarn install \
          && cd .. \
          && Build/node_modules/karma/bin/karma start \
            vendor/typo3/testing-framework/Resources/Core/Build/Configuration/JSUnit/karma.conf.ci.js --single-run
      "

  unitRandom:
    image: typo3gmbh/${DOCKER_PHP_IMAGE}:latest
    user: ${HOST_UID}
    volumes:
      - ${CORE_ROOT}:${CORE_ROOT}
      - ${HOST_HOME}:${HOST_HOME}
      - /etc/passwd:/etc/passwd:ro
      - /etc/group:/etc/group:ro
    working_dir: ${CORE_ROOT}
    command: >
      /bin/sh -c "
        if [ ${SCRIPT_VERBOSE} -eq 1 ]; then
          set -x
        fi
        php -v | grep '^PHP'
        if [ ${PHP_XDEBUG_ON} -eq 0 ]; then
          php -n -c /etc/php/cli-no-xdebug/php.ini \
            vendor/phpunit/phpunit/phpunit -c vendor/typo3/testing-framework/Resources/Core/Build/UnitTests.xml --order-by=random ${EXTRA_TEST_OPTIONS} ${PHPUNIT_RANDOM} ${TEST_FILE};
        else
          DOCKER_HOST=`route -n | awk '/^0.0.0.0/ { print $$2 }'`
          XDEBUG_CONFIG=\"remote_port=${PHP_XDEBUG_PORT} remote_enable=1 remote_host=$${DOCKER_HOST}\" \
            vendor/phpunit/phpunit/phpunit -c vendor/typo3/testing-framework/Resources/Core/Build/UnitTests.xml --order-by=random ${EXTRA_TEST_OPTIONS} ${PHPUNIT_RANDOM} ${TEST_FILE};
        fi
      "
