From ee4fee964e031e771fecf86b314958d81bc573b0 Mon Sep 17 00:00:00 2001 From: Florian ALEXANDRE Date: Thu, 16 Jun 2022 16:36:52 +0200 Subject: [PATCH] feat: add support for Ibexa 4 --- .github/workflows/main-ci.yaml | 2 +- config/services.yml | 45 +++++++++ payload/dev/docker-compose.yml | 12 ++- payload/dev/engine/Dockerfile | 2 +- payload/dev/engine/entrypoint.bash | 10 +- payload/dev/nginx/nginx.conf | 24 ++--- payload/dev/nginx/nginx_v3.conf | 112 +++++++++++++++++++++++ payload/dev/nginx/nginx_v4.conf | 112 +++++++++++++++++++++++ payload/dev/solr/entrypoint.bash | 12 ++- payload/recipes/create_dump.bash | 14 +-- payload/recipes/ez_create.bash | 9 +- payload/recipes/ez_install.bash | 14 +-- payload/recipes/ez_install_solr.bash | 21 +++-- payload/recipes/ibexa_install.bash | 21 ++--- payload/recipes/import_dump.bash | 18 ++-- src/Command/Docker/Create.php | 5 +- src/Command/Docker/Initialize.php | 110 +++++++++++----------- src/Command/Docker/Status.php | 5 +- src/Configuration/CmsVersion.php | 56 ++++++++++++ src/Configuration/CmsVersionRegistry.php | 44 +++++++++ src/Configuration/Configuration.php | 6 ++ src/Core/Client/Docker.php | 24 +++++ src/Core/DockerCommand.php | 17 ++++ src/Core/ProjectStatusDumper.php | 7 +- src/Core/TaskExecutor.php | 6 +- tests/Tests/Command/TestDockerClient.php | 7 ++ tests/Tests/Unit/ConfigurationTest.php | 5 +- tests/Tests/Unit/TestCase.php | 40 ++++---- 28 files changed, 603 insertions(+), 157 deletions(-) create mode 100644 payload/dev/nginx/nginx_v3.conf create mode 100644 payload/dev/nginx/nginx_v4.conf create mode 100644 src/Configuration/CmsVersion.php create mode 100644 src/Configuration/CmsVersionRegistry.php diff --git a/.github/workflows/main-ci.yaml b/.github/workflows/main-ci.yaml index fafc66a..3f3cf78 100644 --- a/.github/workflows/main-ci.yaml +++ b/.github/workflows/main-ci.yaml @@ -77,7 +77,7 @@ jobs: strategy: matrix: php: [7.4, 8.0] - ezversion: [3.*] + ezversion: [3.*, 4.*] collection: [collection-2x.json] steps: - uses: actions/checkout@v1 diff --git a/config/services.yml b/config/services.yml index 7177283..8952e0b 100644 --- a/config/services.yml +++ b/config/services.yml @@ -1,6 +1,47 @@ --- parameters: github_release_url: "https://api.github.com/repos/ezsystems/launchpad/releases?draft=false&prerelease=false" + cms_version_configs: + ezsystems-1: + php_version: "7.2" + solr_version: "6.6.2" + composer_version: 1 + cms_root: /var/www/html/project/ezplatform + document_root: /var/www/html/project/ezplatform/web + console_path: /var/www/html/project/ezplatform/app/console + session_handler: 'ezplatform.core.session.handler.native_redis' + ezsystems-2: + php_version: "7.3" + solr_version: "6.6.2" + composer_version: 1 + cms_root: /var/www/html/project/ezplatform + document_root: /var/www/html/project/ezplatform/web + console_path: /var/www/html/project/ezplatform/bin/console + session_handler: 'ezplatform.core.session.handler.native_redis' + ezsystems-3: + php_version: "7.3" + solr_version: "6.6.2" + composer_version: 1 + cms_root: /var/www/html/project/ezplatform + document_root: /var/www/html/project/ezplatform/web + console_path: /var/www/html/project/ezplatform/bin/console + session_handler: 'ezplatform.core.session.handler.native_redis' + ibexa-3: + php_version: "7.4" + solr_version: "7.7.3" + composer_version: 2 + cms_root: /var/www/html/project/ezplatform + document_root: /var/www/html/project/ezplatform/public + console_path: /var/www/html/project/ezplatform/bin/console + session_handler: 'ezplatform.core.session.handler.native_redis' + ibexa-4: + php_version: "8.1" + solr_version: "7.7.3" + composer_version: 2 + cms_root: /var/www/html/project/ibexa + document_root: /var/www/html/project/ibexa/public + console_path: /var/www/html/project/ibexa/bin/console + session_handler: 'Ibexa\Bundle\Core\Session\Handler\NativeSessionHandler' services: @@ -41,3 +82,7 @@ services: eZ\Launchpad\Core\OSX\Optimizer\NFSVolumes: tags: [ezlaunchpad.osx.optimizer] + + eZ\Launchpad\Configuration\CmsVersionRegistry: + arguments: + $config: '%cms_version_configs%' diff --git a/payload/dev/docker-compose.yml b/payload/dev/docker-compose.yml index bcd2594..3d59ee8 100644 --- a/payload/dev/docker-compose.yml +++ b/payload/dev/docker-compose.yml @@ -5,7 +5,7 @@ services: volumes: - "${PROJECTCOMPOSEPATH}/${PROVISIONINGFOLDERNAME}/dev/nginx/nginx.conf:/etc/nginx/conf.d/default.conf:ro" - "${PROJECTCOMPOSEPATH}/${PROVISIONINGFOLDERNAME}/dev/nginx/entrypoint.bash:/entrypoint.bash:ro" - - "${PROJECTCOMPOSEPATH}/ezplatform/doc/nginx/ez_params.d:/etc/nginx/ez_params.d:ro" + - "${PROJECTCOMPOSEPATH}/${PROVISIONINGFOLDERNAME}/dev/nginx/include/ez_params.d:/etc/nginx/ez_params.d:ro" depends_on: - engine volumes_from: @@ -27,7 +27,10 @@ services: shm_size: 754M environment: - COMPOSER_CACHE_DIR + - PROJECTCMSROOT - PROJECTMAPPINGFOLDER + - PROVISIONINGFOLDERNAME + - CONSOLE_PATH - DEV_UID - DEV_GID - XDEBUG_ENABLED @@ -42,6 +45,7 @@ services: - "DATABASE_PASSWORD=ezplatform" - "SYMFONY_SECRET=eZlaunchpad20Secret09Dev83ModeZ" - "APP_SECRET=eZlaunchpad20Secret09Dev83ModeZ" + - "SOLR_VERSION=$SOLR_VERSION" - "DATABASE_HOST=db" - "CUSTOM_CACHE_POOL=singleredis" - "CACHE_HOST=redis" @@ -54,7 +58,7 @@ services: - "APP_CACHE_DIR=/tmp/ezplatformcache/" - "APP_LOG_DIR=/tmp/ezplatformlogs/" - "HTTPCACHE_VARNISH_INVALIDATE_TOKEN=eZlaunchpad20Secret09Varnish" - - "SESSION_HANDLER_ID=ezplatform.core.session.handler.native_redis" + - "SESSION_HANDLER_ID=${PROJECT_SESSION_HANDLER_ID}" - "SESSION_SAVE_PATH=tcp://redis:6379" db: image: mariadb:10.3 @@ -73,7 +77,7 @@ services: - nginx solr: - image: solr:7.7 + image: solr:$SOLR_VERSION volumes: - "${PROJECTCOMPOSEPATH}/${PROVISIONINGFOLDERNAME}/dev/solr/entrypoint.bash:/entrypoint.bash:ro" volumes_from: @@ -86,7 +90,9 @@ services: environment: - DEV_UID - DEV_GID + - PROJECTCMSROOT - PROJECTMAPPINGFOLDER + - SOLR_VERSION=$SOLR_VERSION - SOLR_CORES=collection1 # Mailcatcher diff --git a/payload/dev/engine/Dockerfile b/payload/dev/engine/Dockerfile index 84a7337..d1e0fb0 100644 --- a/payload/dev/engine/Dockerfile +++ b/payload/dev/engine/Dockerfile @@ -1,4 +1,4 @@ -FROM plopix/docker-php-ez-engine:7.4 +FROM plopix/docker-php-ez-engine:$PHP_VERSION MAINTAINER Plopix ENV XDEBUG_ENABLED=0 diff --git a/payload/dev/engine/entrypoint.bash b/payload/dev/engine/entrypoint.bash index 3a4ea90..7ed5d27 100755 --- a/payload/dev/engine/entrypoint.bash +++ b/payload/dev/engine/entrypoint.bash @@ -18,11 +18,11 @@ chown www-data:www-data $PROJECTMAPPINGFOLDER # give the good permissions to www-data in the container and remove the cache on start # 2.x -if [ -d $PROJECTMAPPINGFOLDER/ezplatform/var/cache ]; then - rm -rf $PROJECTMAPPINGFOLDER/ezplatform/var/cache +if [ -d $PROJECTCMSROOT/var/cache ]; then + rm -rf $PROJECTCMSROOT/var/cache rm -rf $SYMFONY_TMP_DIR/var/cache - chown -R www-data:www-data $PROJECTMAPPINGFOLDER/ezplatform/var/logs - chown -R www-data:www-data $PROJECTMAPPINGFOLDER/ezplatform/web + chown -R www-data:www-data $PROJECTCMSROOT/var/logs + chown -R www-data:www-data $PROJECTCMSROOT/web fi if [ ! -f /usr/local/bin/composer ]; @@ -30,7 +30,7 @@ then echo "WARNING: you don't have the last image of the PHP ENGINE" echo "TO FIX RUN: ~/ez docker:update" fi -/usr/local/bin/composer self-update --1 +/usr/local/bin/composer self-update --$COMPOSER_VERSION if [ "1" = "${XDEBUG_ENABLED}" ]; then export PHP_INI_SCAN_DIR=:/usr/local/etc/php/enable-xdebug diff --git a/payload/dev/nginx/nginx.conf b/payload/dev/nginx/nginx.conf index 7eccc7f..a0775e0 100644 --- a/payload/dev/nginx/nginx.conf +++ b/payload/dev/nginx/nginx.conf @@ -13,7 +13,7 @@ server { server_name _; # Project Root = project-path-container = /var/www/html/project # Would be great to get that from ENV var PROJECTMAPPINGFOLDER - root "/var/www/html/project/ezplatform/public"; + root "/var/www/html/project/ezplatform/web"; # FOR DFS # include ez_params.d/ez_rewrite_dfsimage_params; @@ -28,10 +28,10 @@ server { fastcgi_read_timeout 30; location / { - location ~ ^/index\.php(/|$) { + location ~ ^/app\.php(/|$) { include ez_params.d/ez_fastcgi_params; fastcgi_pass engine:9000; - fastcgi_param APP_ENV dev; + fastcgi_param SYMFONY_ENV dev; fastcgi_param RUNNING_ENV DOCKER; } } @@ -44,7 +44,7 @@ server { server_name _; # Project Root = project-path-container = /var/www/html/project # Would be great to get that from ENV var PROJECTMAPPINGFOLDER - root "/var/www/html/project/ezplatform/public"; + root "/var/www/html/project/ezplatform/web"; include ez_params.d/ez_prod_rewrite_params; @@ -61,11 +61,11 @@ server { fastcgi_read_timeout 30; location / { - location ~ ^/index\.php(/|$) { + location ~ ^/app\.php(/|$) { include ez_params.d/ez_fastcgi_params; fastcgi_pass engine:9000; - fastcgi_param APP_ENV prod; + fastcgi_param SYMFONY_ENV prod; fastcgi_param RUNNING_ENV DOCKER; } } @@ -79,7 +79,7 @@ server { server_name _; # Project Root = project-path-container = /var/www/html/project # Would be great to get that from ENV var PROJECTMAPPINGFOLDER - root "/var/www/html/project/ezplatform/public"; + root "/var/www/html/project/ezplatform/web"; include ez_params.d/ez_prod_rewrite_params; @@ -96,16 +96,16 @@ server { fastcgi_read_timeout 30; location / { - location ~ ^/index\.php(/|$) { + location ~ ^/app\.php(/|$) { include ez_params.d/ez_fastcgi_params; fastcgi_pass engine:9000; - fastcgi_param APP_ENV prod; + fastcgi_param SYMFONY_ENV prod; fastcgi_param RUNNING_ENV DOCKER; - fastcgi_param APP_HTTP_CACHE 0; - fastcgi_param HTTPCACHE_PURGE_TYPE varnish; + fastcgi_param SYMFONY_HTTP_CACHE 0; + fastcgi_param HTTPCACHE_PURGE_TYPE http; fastcgi_param HTTPCACHE_PURGE_SERVER 'http://varnish:80'; - fastcgi_param TRUSTED_PROXIES "127.0.0.1,localhost,172.0.0.0/8,varnish,192.168.0.0/16"; + fastcgi_param SYMFONY_TRUSTED_PROXIES "127.0.0.1,localhost,172.0.0.0/8,varnish"; } } include ez_params.d/ez_server_params; diff --git a/payload/dev/nginx/nginx_v3.conf b/payload/dev/nginx/nginx_v3.conf new file mode 100644 index 0000000..7eccc7f --- /dev/null +++ b/payload/dev/nginx/nginx_v3.conf @@ -0,0 +1,112 @@ +# GZIP +gzip on; +gzip_disable "msie6"; +gzip_proxied any; +gzip_comp_level 6; +gzip_buffers 16 8k; +gzip_http_version 1.1; +gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript; + +# DEV MODE +server { + listen 80; + server_name _; + # Project Root = project-path-container = /var/www/html/project + # Would be great to get that from ENV var PROJECTMAPPINGFOLDER + root "/var/www/html/project/ezplatform/public"; + + # FOR DFS + # include ez_params.d/ez_rewrite_dfsimage_params; + + # ez rewrite rules + include ez_params.d/ez_rewrite_params; + + # upload max size + client_max_body_size 40M; + + # FPM fastcgi_read_timeout + fastcgi_read_timeout 30; + + location / { + location ~ ^/index\.php(/|$) { + include ez_params.d/ez_fastcgi_params; + fastcgi_pass engine:9000; + fastcgi_param APP_ENV dev; + fastcgi_param RUNNING_ENV DOCKER; + } + } + include ez_params.d/ez_server_params; +} + +# PROD MODE - Symfony Reverse Proxy +server { + listen 81; + server_name _; + # Project Root = project-path-container = /var/www/html/project + # Would be great to get that from ENV var PROJECTMAPPINGFOLDER + root "/var/www/html/project/ezplatform/public"; + + include ez_params.d/ez_prod_rewrite_params; + + # FOR DFS + # include ez_params.d/ez_rewrite_dfsimage_params; + + # ez rewrite rules + include ez_params.d/ez_rewrite_params; + + # upload max size + client_max_body_size 40M; + + # FPM fastcgi_read_timeout + fastcgi_read_timeout 30; + + location / { + location ~ ^/index\.php(/|$) { + include ez_params.d/ez_fastcgi_params; + + fastcgi_pass engine:9000; + fastcgi_param APP_ENV prod; + fastcgi_param RUNNING_ENV DOCKER; + } + } + include ez_params.d/ez_server_params; +} + + +# PROD MODE - Varnish +server { + listen 82; + server_name _; + # Project Root = project-path-container = /var/www/html/project + # Would be great to get that from ENV var PROJECTMAPPINGFOLDER + root "/var/www/html/project/ezplatform/public"; + + include ez_params.d/ez_prod_rewrite_params; + + # FOR DFS + # include ez_params.d/ez_rewrite_dfsimage_params; + + # ez rewrite rules + include ez_params.d/ez_rewrite_params; + + # upload max size + client_max_body_size 40M; + + # FPM fastcgi_read_timeout + fastcgi_read_timeout 30; + + location / { + location ~ ^/index\.php(/|$) { + include ez_params.d/ez_fastcgi_params; + + fastcgi_pass engine:9000; + fastcgi_param APP_ENV prod; + fastcgi_param RUNNING_ENV DOCKER; + fastcgi_param APP_HTTP_CACHE 0; + fastcgi_param HTTPCACHE_PURGE_TYPE varnish; + fastcgi_param HTTPCACHE_PURGE_SERVER 'http://varnish:80'; + fastcgi_param TRUSTED_PROXIES "127.0.0.1,localhost,172.0.0.0/8,varnish,192.168.0.0/16"; + } + } + include ez_params.d/ez_server_params; +} diff --git a/payload/dev/nginx/nginx_v4.conf b/payload/dev/nginx/nginx_v4.conf new file mode 100644 index 0000000..2236c33 --- /dev/null +++ b/payload/dev/nginx/nginx_v4.conf @@ -0,0 +1,112 @@ +# GZIP +gzip on; +gzip_disable "msie6"; +gzip_proxied any; +gzip_comp_level 6; +gzip_buffers 16 8k; +gzip_http_version 1.1; +gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript; + +# DEV MODE +server { + listen 80; + server_name _; + # Project Root = project-path-container = /var/www/html/project + # Would be great to get that from ENV var PROJECTMAPPINGFOLDER + root "/var/www/html/project/ibexa/public"; + + # FOR DFS + # include ez_params.d/ez_rewrite_dfsimage_params; + + # ez rewrite rules + include ez_params.d/ez_rewrite_params; + + # upload max size + client_max_body_size 40M; + + # FPM fastcgi_read_timeout + fastcgi_read_timeout 30; + + location / { + location ~ ^/index\.php(/|$) { + include ez_params.d/ez_fastcgi_params; + fastcgi_pass engine:9000; + fastcgi_param APP_ENV dev; + fastcgi_param RUNNING_ENV DOCKER; + } + } + include ez_params.d/ez_server_params; +} + +# PROD MODE - Symfony Reverse Proxy +server { + listen 81; + server_name _; + # Project Root = project-path-container = /var/www/html/project + # Would be great to get that from ENV var PROJECTMAPPINGFOLDER + root "/var/www/html/project/ibexa/public"; + + include ez_params.d/ez_prod_rewrite_params; + + # FOR DFS + # include ez_params.d/ez_rewrite_dfsimage_params; + + # ez rewrite rules + include ez_params.d/ez_rewrite_params; + + # upload max size + client_max_body_size 40M; + + # FPM fastcgi_read_timeout + fastcgi_read_timeout 30; + + location / { + location ~ ^/index\.php(/|$) { + include ez_params.d/ez_fastcgi_params; + + fastcgi_pass engine:9000; + fastcgi_param APP_ENV prod; + fastcgi_param RUNNING_ENV DOCKER; + } + } + include ez_params.d/ez_server_params; +} + + +# PROD MODE - Varnish +server { + listen 82; + server_name _; + # Project Root = project-path-container = /var/www/html/project + # Would be great to get that from ENV var PROJECTMAPPINGFOLDER + root "/var/www/html/project/ibexa/public"; + + include ez_params.d/ez_prod_rewrite_params; + + # FOR DFS + # include ez_params.d/ez_rewrite_dfsimage_params; + + # ez rewrite rules + include ez_params.d/ez_rewrite_params; + + # upload max size + client_max_body_size 40M; + + # FPM fastcgi_read_timeout + fastcgi_read_timeout 30; + + location / { + location ~ ^/index\.php(/|$) { + include ez_params.d/ez_fastcgi_params; + + fastcgi_pass engine:9000; + fastcgi_param APP_ENV prod; + fastcgi_param RUNNING_ENV DOCKER; + fastcgi_param APP_HTTP_CACHE 0; + fastcgi_param HTTPCACHE_PURGE_TYPE varnish; + fastcgi_param HTTPCACHE_PURGE_SERVER 'http://varnish:80'; + fastcgi_param TRUSTED_PROXIES "127.0.0.1,localhost,172.0.0.0/8,varnish,192.168.0.0/16"; + } + } + include ez_params.d/ez_server_params; +} diff --git a/payload/dev/solr/entrypoint.bash b/payload/dev/solr/entrypoint.bash index bea37c7..d22f9b3 100755 --- a/payload/dev/solr/entrypoint.bash +++ b/payload/dev/solr/entrypoint.bash @@ -4,9 +4,17 @@ DESTINATION_EZ="/ezsolr/server/ez" DESTINATION_TEMPLATE="${DESTINATION_EZ}/template" if [ ! -d ${DESTINATION_TEMPLATE} ]; then - cd $PROJECTMAPPINGFOLDER/ezplatform + cd $PROJECTCMSROOT mkdir -p ${DESTINATION_TEMPLATE} - cp -R vendor/ezsystems/ezplatform-solr-search-engine/lib/Resources/config/solr/* ${DESTINATION_TEMPLATE} + + if [ -f ./vendor/ibexa/solr/bin/generate-solr-config.sh ]; then + ./vendor/ibexa/solr/bin/generate-solr-config.sh \ + --destination-dir=$DESTINATION_TEMPLATE \ + --solr-version=$SOLR_VERSION \ + --force + else + cp -R vendor/ezsystems/ezplatform-solr-search-engine/lib/Resources/config/solr/* ${DESTINATION_TEMPLATE} + fi fi # Check for solr config folder (changes btw 6 and 7) diff --git a/payload/recipes/create_dump.bash b/payload/recipes/create_dump.bash index 4e809a9..534b2bb 100755 --- a/payload/recipes/create_dump.bash +++ b/payload/recipes/create_dump.bash @@ -20,16 +20,16 @@ do DATABASE_HOST_VAR=${prefix}_HOST DATABASE_USER_VAR=${prefix}_USER DATABASE_PASSWORD_VAR=${prefix}_PASSWORD - + # Wait for the DB while ! mysqladmin ping -h"${!DATABASE_HOST_VAR}" -u"${!DATABASE_USER_VAR}" -p"${!DATABASE_PASSWORD_VAR}" --silent; do echo -n "." sleep 1 done echo "" - + DB_FILE_NAME="${!DATABASE_NAME_VAR}" - + MYSQLDUMP="mysqldump -h${!DATABASE_HOST_VAR} -u${!DATABASE_USER_VAR} -p${!DATABASE_PASSWORD_VAR}" echo "Dumping ${!DATABASE_NAME_VAR} database." @@ -45,15 +45,15 @@ if [ "$2" != "" ]; then STORAGE_FILE_NAME="$2_storage" fi -if [ -d $PROJECTMAPPINGFOLDER/ezplatform/web/var ]; then - cd $PROJECTMAPPINGFOLDER/ezplatform/web +if [ -d $PROJECTCMSROOT/web/var ]; then + cd $PROJECTCMSROOT/web tar czvf $DUMP_DIR/$STORAGE_FILE_NAME.tar.gz var/ cd - echo "Storage dumped from web/." fi -if [ -d $PROJECTMAPPINGFOLDER/ezplatform/public/var ]; then - cd $PROJECTMAPPINGFOLDER/ezplatform/public +if [ -d $PROJECTCMSROOT/public/var ]; then + cd $PROJECTCMSROOT/public tar czvf $DUMP_DIR/$STORAGE_FILE_NAME.tar.gz var/ cd - echo "Storage dumped from public/." diff --git a/payload/recipes/ez_create.bash b/payload/recipes/ez_create.bash index 5b3e6d3..6e874ca 100755 --- a/payload/recipes/ez_create.bash +++ b/payload/recipes/ez_create.bash @@ -25,18 +25,13 @@ do mysql -h"${!DATABASE_HOST_VAR}" -u"${!DATABASE_USER_VAR}" -p"${!DATABASE_PASSWORD_VAR}" -e "CREATE DATABASE ${!DATABASE_NAME_VAR}" done -if [ ! -d ezplatform ]; then +if [ ! -d $PROJECTCMSROOT ]; then echo "Not managed yet." exit fi -CONSOLE="bin/console" -if [ -f ezplatform/app/console ]; then - CONSOLE="app/console" -fi - # Install -cd ezplatform +cd $PROJECTCMSROOT $COMPOSER install --no-interaction diff --git a/payload/recipes/ez_install.bash b/payload/recipes/ez_install.bash index d74d598..f10907b 100755 --- a/payload/recipes/ez_install.bash +++ b/payload/recipes/ez_install.bash @@ -29,8 +29,10 @@ done echo "Installation eZ Platform ($REPO:$VERSION:$INIT_DATA) in the container" # Install -$COMPOSER create-project --no-interaction $REPO ezplatform $VERSION -cd ezplatform +$COMPOSER create-project --no-interaction $REPO $PROJECTCMSROOT $VERSION +cd $PROJECTCMSROOT + +cp -r doc/nginx/ $PROJECTMAPPINGFOLDER/$PROVISIONINGFOLDERNAME/dev/nginx/include MAJOR_VERSION=`echo $VERSION | cut -c 1-2` @@ -38,17 +40,11 @@ MAJOR_VERSION=`echo $VERSION | cut -c 1-2` ## Folder rm -rf bin/.ci bin/.travis -CONSOLE="bin/console" -if [ -f app/console ]; then - CONSOLE="app/console" -fi - - # Prefer install via composer alias (added in v2.2, required for eZ Commerce) if $COMPOSER run-script -l | grep -q " $INIT_DATA "; then $COMPOSER run-script $INIT_DATA else - $PHP $CONSOLE ezplatform:install $INIT_DATA + $PHP $CONSOLE_PATH ezplatform:install $INIT_DATA fi diff --git a/payload/recipes/ez_install_solr.bash b/payload/recipes/ez_install_solr.bash index 77cc664..6958ec4 100755 --- a/payload/recipes/ez_install_solr.bash +++ b/payload/recipes/ez_install_solr.bash @@ -9,9 +9,18 @@ PHP="php" if [ $ACTION == "COMPOSER_INSTALL" ]; then # it is run on the engine - cd $PROJECTMAPPINGFOLDER/ezplatform + cd $PROJECTCMSROOT mkdir -p $DESTINATION_TEMPLATE - cp -R vendor/ezsystems/ezplatform-solr-search-engine/lib/Resources/config/solr/* $DESTINATION_TEMPLATE + if [ -f ./vendor/ibexa/solr/bin/generate-solr-config.sh ]; then + echo "Generating configuration for SOLR $SOLR_VERSION" + ./vendor/ibexa/solr/bin/generate-solr-config.sh \ + --destination-dir=$DESTINATION_TEMPLATE \ + --solr-version=$SOLR_VERSION \ + --force + else + echo "Copying configuration for SOLR $SOLR_VERSION" + cp -R vendor/ezsystems/ezplatform-solr-search-engine/lib/Resources/config/solr/* ${DESTINATION_TEMPLATE} + fi # simplest way to allow solr to add the conf here... from its own container # We could do better by extending the Dockerfile and build.. but it is also less "generic" chmod -R 777 $DESTINATION_EZ @@ -26,12 +35,8 @@ if [ $ACTION == "INDEX" ]; then # wait cores sleep 15 echo "Solr is running" - cd $PROJECTMAPPINGFOLDER/ezplatform - CONSOLE="bin/console" - if [ -f app/console ]; then - CONSOLE="app/console" - fi - $PHP $CONSOLE --env=prod ezplatform:reindex + cd $PROJECTCMSROOT + $PHP $CONSOLE_PATH --env=prod ezplatform:reindex fi if [ $ACTION == "CREATE_CORE" ]; then diff --git a/payload/recipes/ibexa_install.bash b/payload/recipes/ibexa_install.bash index 72fa30c..b5bbe82 100755 --- a/payload/recipes/ibexa_install.bash +++ b/payload/recipes/ibexa_install.bash @@ -8,7 +8,6 @@ REPO=$1 VERSION=$2 INIT_DATA=$3 DATABASE_PREFIXES=${DATABASE_PREFIXES:-DATABASE} -CONSOLE="bin/console" for prefix in $DATABASE_PREFIXES do @@ -29,19 +28,19 @@ done echo "Installation Ibexa ($REPO - $VERSION) in the container" -# Install ibexa/website-skeleton -echo "Install ibexa/website-skeleton" -$COMPOSER create-project --no-interaction $REPO-skeleton ezplatform $VERSION -cd ezplatform # Copy nginx conf echo "Getting the NGINX config" wget https://github.com/ibexa/docker/archive/main.zip unzip main.zip -mkdir -p doc -cp -r docker-main/templates/nginx doc/ +cp -r docker-main/templates/nginx/ $PROJECTMAPPINGFOLDER/$PROVISIONINGFOLDERNAME/dev/nginx/include rm -rf docker-main rm main.zip +# Install ibexa/website-skeleton +echo "Install $REPO-skeleton" +$COMPOSER create-project --no-interaction $REPO-skeleton $PROJECTCMSROOT $VERSION +cd $PROJECTCMSROOT + # Add .env.local to set database configuration echo "Add .env.local to set database configuration" echo "DATABASE_URL=\${DATABASE_PLATFORM}://\${DATABASE_USER}:\${DATABASE_PASSWORD}@\${DATABASE_HOST}:\${DATABASE_PORT}/\${DATABASE_NAME}?serverVersion=\${DATABASE_VERSION}" > ".env.local" @@ -64,11 +63,11 @@ echo "Installation Ibexa $REPO OK" if $COMPOSER run-script -l | grep -q " $INIT_DATA "; then $COMPOSER run-script $INIT_DATA else - echo "php bin/console ibexa:install " - $PHP $CONSOLE ibexa:install $INIT_DATA + echo "php $CONSOLE_PATH ibexa:install " + $PHP $CONSOLE_PATH ibexa:install $INIT_DATA fi -echo "php bin/console ibexa:graphql:generate-schema" -$PHP $CONSOLE ibexa:graphql:generate-schema +echo "php $CONSOLE_PATH ibexa:graphql:generate-schema" +$PHP $CONSOLE_PATH ibexa:graphql:generate-schema echo "composer run post-update-cmd" $COMPOSER run-script post-install-cmd diff --git a/payload/recipes/import_dump.bash b/payload/recipes/import_dump.bash index 4889625..a2bcad1 100755 --- a/payload/recipes/import_dump.bash +++ b/payload/recipes/import_dump.bash @@ -43,24 +43,24 @@ fi STORAGE_FILE_PATH="$DUMP_DIR/$STORAGE_FILE_NAME.tar.gz" -if [ ! -d ezplatform ]; then +if [ ! -d $PROJECTCMSROOT ]; then echo "Not managed yet." exit fi if [ -f $STORAGE_FILE_PATH ]; then - if [ -d ezplatform/web ]; then - if [ -d "ezplatform/web/var" ]; then - rm -rf ezplatform/web/var + if [ -d $PROJECTCMSROOT/web ]; then + if [ -d "$PROJECTCMSROOT/web/var" ]; then + rm -rf $PROJECTCMSROOT/web/var fi - tar xvzf $STORAGE_FILE_PATH -C ezplatform/web/ + tar xvzf $STORAGE_FILE_PATH -C $PROJECTCMSROOT/web/ echo "Storage imported to web/." fi - if [ -d ezplatform/public ]; then - if [ -d "ezplatform/public/var" ]; then - rm -rf ezplatform/public/var + if [ -d $PROJECTCMSROOT/public ]; then + if [ -d "${PROJECTCMSROOT}/public/var" ]; then + rm -rf $PROJECTCMSROOT/public/var fi - tar xvzf $STORAGE_FILE_PATH -C ezplatform/public/ + tar xvzf $STORAGE_FILE_PATH -C $PROJECTCMSROOT/public/ echo "Storage imported to public/." fi fi diff --git a/src/Command/Docker/Create.php b/src/Command/Docker/Create.php index 9838244..7100452 100644 --- a/src/Command/Docker/Create.php +++ b/src/Command/Docker/Create.php @@ -9,6 +9,7 @@ namespace eZ\Launchpad\Command\Docker; +use eZ\Launchpad\Configuration\CmsVersionRegistry; use eZ\Launchpad\Core\DockerCommand; use eZ\Launchpad\Core\ProjectStatusDumper; use Symfony\Component\Console\Input\InputInterface; @@ -21,9 +22,9 @@ final class Create extends DockerCommand */ protected $projectStatusDumper; - public function __construct(ProjectStatusDumper $projectStatusDumper) + public function __construct(CmsVersionRegistry $cmsVersionRegistry, ProjectStatusDumper $projectStatusDumper) { - parent::__construct(); + parent::__construct($cmsVersionRegistry); $this->projectStatusDumper = $projectStatusDumper; } diff --git a/src/Command/Docker/Initialize.php b/src/Command/Docker/Initialize.php index 9ddb6bc..40754bc 100644 --- a/src/Command/Docker/Initialize.php +++ b/src/Command/Docker/Initialize.php @@ -9,6 +9,7 @@ namespace eZ\Launchpad\Command\Docker; +use eZ\Launchpad\Configuration\CmsVersionRegistry; use eZ\Launchpad\Console\Application; use eZ\Launchpad\Core\Client\Docker; use eZ\Launchpad\Core\Command; @@ -29,10 +30,16 @@ class Initialize extends Command */ protected $projectStatusDumper; - public function __construct(ProjectStatusDumper $projectStatusDumper) + /** + * @var CmsVersionRegistry + */ + protected $cmsVersionRegistry; + + public function __construct(ProjectStatusDumper $projectStatusDumper, CmsVersionRegistry $cmsVersionRegistry) { parent::__construct(); $this->projectStatusDumper = $projectStatusDumper; + $this->cmsVersionRegistry = $cmsVersionRegistry; } protected function initialize(InputInterface $input, OutputInterface $output): void @@ -61,7 +68,7 @@ private function isIbexa(InputInterface $input): bool return false !== strpos($input->getArgument('repository'), 'ibexa'); } - private function getEzPlatformMajorVersion(InputInterface $input): int + private function getEzPlatformMajorVersion(InputInterface $input): string { $normalizedVersion = trim($input->getArgument('version'), 'v'); $normalizedProvider = explode( @@ -76,7 +83,7 @@ private function getEzPlatformMajorVersion(InputInterface $input): int ++$normalizedMajorVersion; } - return $normalizedMajorVersion; + return sprintf('%s-%d', $normalizedProvider, $normalizedMajorVersion); } protected function execute(InputInterface $input, OutputInterface $output): int @@ -113,76 +120,65 @@ protected function execute(InputInterface $input, OutputInterface $output): int unset($selectedServices); $eZMajorVersion = $this->getEzPlatformMajorVersion($input); - - // eZ Platform 1.x specific versions - if (1 === $eZMajorVersion) { - // PHP 7.2 - $enginDockerFilePath = "{$provisioningFolder}/dev/engine/Dockerfile"; - $engineDockerFileContent = file_get_contents($enginDockerFilePath); - file_put_contents( - $enginDockerFilePath, - str_replace( - 'docker-php-ez-engine:7.4', - 'docker-php-ez-engine:7.2', - $engineDockerFileContent - ) - ); - } - - // eZ Platform 2.x specific versions - if (2 === $eZMajorVersion) { - // PHP 7.3 - $enginDockerFilePath = "{$provisioningFolder}/dev/engine/Dockerfile"; - $engineDockerFileContent = file_get_contents($enginDockerFilePath); - file_put_contents( - $enginDockerFilePath, - str_replace( - 'docker-php-ez-engine:7.4', - 'docker-php-ez-engine:7.3', - $engineDockerFileContent - ) - ); - } + $this->projectConfiguration->setLocal('project.cms_version', $eZMajorVersion); + + $versionConfig = $this->cmsVersionRegistry->getVersion($eZMajorVersion); + + // Set php version according to CMS version + $enginDockerFilePath = "{$provisioningFolder}/dev/engine/Dockerfile"; + $engineDockerFileContent = file_get_contents($enginDockerFilePath); + file_put_contents( + $enginDockerFilePath, + str_replace( + '$PHP_VERSION', + (string) $versionConfig->phpVersion, + $engineDockerFileContent + ) + ); // eZ Platform < 3 has another vhost - if ($eZMajorVersion < 3) { - rename("{$provisioningFolder}/dev/nginx/nginx_v2.conf", "{$provisioningFolder}/dev/nginx/nginx.conf"); + $vhostConfFiles = [ + 'ezsystems-2' => "{$provisioningFolder}/dev/nginx/nginx_v2.conf", + 'ezsystems-3' => "{$provisioningFolder}/dev/nginx/nginx_v2.conf", + 'ibexa-3' => "{$provisioningFolder}/dev/nginx/nginx_v3.conf", + 'ibexa-4' => "{$provisioningFolder}/dev/nginx/nginx_v4.conf", + ]; + if (isset($vhostConfFiles[$eZMajorVersion])) { + rename($vhostConfFiles[$eZMajorVersion], "{$provisioningFolder}/dev/nginx/nginx.conf"); + } + foreach ($vhostConfFiles as $vhostCmsVersion => $vhostConfFile) { + if ($vhostCmsVersion !== $eZMajorVersion && file_exists($vhostConfFile)) { + unlink($vhostConfFile); + } } // eZ Platform < 3 only support solr 6. Replace unsupported solr 7.7 by 6.6.2 - if ($compose->hasService('solr') && ($eZMajorVersion < 3)) { + if ($compose->hasService('solr')) { $composeFilePath = "{$provisioningFolder}/dev/{$composeFileName}"; $compose->dump($composeFilePath); $composeFileContent = file_get_contents($composeFilePath); file_put_contents( $composeFilePath, str_replace( - 'solr:7.7', - 'solr:6.6.2', + '$SOLR_VERSION', + (string) $versionConfig->solrVersion, $composeFileContent ) ); $compose = new DockerCompose($composeFilePath); } - // no need for v2 nginx on v3 - if ($eZMajorVersion >= 3) { - unlink("{$provisioningFolder}/dev/nginx/nginx_v2.conf"); - } - // Ibexa >= 3.3.x , update composer to v2 - if ($this->isIbexa($input)) { - $engineEntryPointPath = "{$provisioningFolder}/dev/engine/entrypoint.bash"; - $engineEntryPointContent = file_get_contents($engineEntryPointPath); - file_put_contents( - $engineEntryPointPath, - str_replace( - 'self-update --1', - 'self-update --2', - $engineEntryPointContent - ) - ); - } + $engineEntryPointPath = "{$provisioningFolder}/dev/engine/entrypoint.bash"; + $engineEntryPointContent = file_get_contents($engineEntryPointPath); + file_put_contents( + $engineEntryPointPath, + str_replace( + '$COMPOSER_VERSION', + (string) $versionConfig->composerVersion, + $engineEntryPointContent + ) + ); // Clean the Compose File $compose->removeUselessEnvironmentsVariables(); @@ -216,6 +212,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int 'provisioning-folder-name' => $provisioningName, 'host-machine-mapping' => $this->projectConfiguration->get('docker.host_machine_mapping'), 'composer-cache-dir' => $this->projectConfiguration->get('docker.host_composer_cache_dir'), + 'project-cms-path-container' => $versionConfig->cmsRoot, + 'project-session-handler' => $versionConfig->sessionHandler, + 'project-session-handler' => $versionConfig->sessionHandler, + 'console-path' => $versionConfig->consolePath, ]; $dockerClient = new Docker($options, new ProcessRunner(), $this->optimizer); $this->projectStatusDumper->setDockerClient($dockerClient); diff --git a/src/Command/Docker/Status.php b/src/Command/Docker/Status.php index 70bef59..58f4344 100644 --- a/src/Command/Docker/Status.php +++ b/src/Command/Docker/Status.php @@ -9,6 +9,7 @@ namespace eZ\Launchpad\Command\Docker; +use eZ\Launchpad\Configuration\CmsVersionRegistry; use eZ\Launchpad\Core\DockerCommand; use eZ\Launchpad\Core\ProjectStatusDumper; use Symfony\Component\Console\Input\InputArgument; @@ -22,9 +23,9 @@ final class Status extends DockerCommand */ protected $projectStatusDumper; - public function __construct(ProjectStatusDumper $projectStatusDumper) + public function __construct(CmsVersionRegistry $cmsVersionRegistry, ProjectStatusDumper $projectStatusDumper) { - parent::__construct(); + parent::__construct($cmsVersionRegistry); $this->projectStatusDumper = $projectStatusDumper; } diff --git a/src/Configuration/CmsVersion.php b/src/Configuration/CmsVersion.php new file mode 100644 index 0000000..9accdb5 --- /dev/null +++ b/src/Configuration/CmsVersion.php @@ -0,0 +1,56 @@ +phpVersion = $phpVersion; + $this->solrVersion = $solrVersion; + $this->composerVersion = $composerVersion; + $this->documentRoot = $documentRoot; + $this->cmsRoot = $cmsRoot; + $this->sessionHandler = $sessionHandler; + $this->consolePath = $consolePath; + } +} diff --git a/src/Configuration/CmsVersionRegistry.php b/src/Configuration/CmsVersionRegistry.php new file mode 100644 index 0000000..df1b683 --- /dev/null +++ b/src/Configuration/CmsVersionRegistry.php @@ -0,0 +1,44 @@ + $versionConfig) { + $this->addVersion( + $versionNumber, + new CmsVersion( + $versionConfig['php_version'], + $versionConfig['solr_version'], + $versionConfig['composer_version'], + $versionConfig['document_root'], + $versionConfig['cms_root'], + $versionConfig['session_handler'], + $versionConfig['console_path'], + ) + ); + } + } + + public function addVersion(string $versionNumber, CmsVersion $cmsVersion) + { + $this->versions[$versionNumber] = $cmsVersion; + } + + public function getVersion(string $versionNumber): CmsVersion + { + return $this->versions[$versionNumber]; + } +} diff --git a/src/Configuration/Configuration.php b/src/Configuration/Configuration.php index 136f74e..bb5c59a 100644 --- a/src/Configuration/Configuration.php +++ b/src/Configuration/Configuration.php @@ -58,6 +58,12 @@ public function getConfigTreeBuilder(): TreeBuilder ->end() ->end() ->scalarNode('last_update_check')->defaultNull()->end() + ->arrayNode('project') + ->addDefaultsIfNotSet() + ->children() + ->scalarNode('cms_version')->defaultValue('ibexa-4')->end() + ->end() + ->end() ->end(); return $treeBuilder; diff --git a/src/Core/Client/Docker.php b/src/Core/Client/Docker.php index c00f58a..5ec9584 100644 --- a/src/Core/Client/Docker.php +++ b/src/Core/Client/Docker.php @@ -45,6 +45,9 @@ public function __construct(array $options, ProcessRunner $runner, ?OptimizerInt 'host-machine-mapping' => null, 'provisioning-folder-name' => null, 'composer-cache-dir' => null, + 'project-cms-path-container' => '/var/www/html/project/ibexa', + 'project-session-handler' => null, + 'console-path' => '/var/www/html/project/ibexa/bin/console', ]; $resolver->setDefaults($defaults); $resolver->setRequired(array_keys($defaults)); @@ -56,6 +59,9 @@ public function __construct(array $options, ProcessRunner $runner, ?OptimizerInt $resolver->setAllowedTypes('provisioning-folder-name', 'string'); $resolver->setAllowedTypes('network-prefix-port', 'int'); $resolver->setAllowedTypes('host-machine-mapping', ['null', 'string']); + $resolver->setAllowedTypes('project-cms-path-container', 'string'); + $resolver->setAllowedTypes('project-session-handler', 'string'); + $resolver->setAllowedTypes('console-path', 'string'); $this->options = $resolver->resolve($options); $this->runner = $runner; $this->optimizer = $optimizer; @@ -108,6 +114,21 @@ protected function getMachineMountPath(): string return explode(':', $this->options['host-machine-mapping'])[1]; } + public function getProjectCmsPathContainer(): string + { + return $this->options['project-cms-path-container']; + } + + protected function getProjectSessionHandler(): string + { + return $this->options['project-session-handler']; + } + + public function getConsolePath(): string + { + return $this->options['console-path']; + } + public function start(string $service = '') { return $this->perform('start', $service); @@ -196,6 +217,9 @@ public function getComposeEnvVariables(): array 'COMPOSER_CACHE_DIR' => '/var/www/composer_cache', // where to mount the project root directory in the container - (will be mapped to host:project-path) 'PROJECTMAPPINGFOLDER' => $this->getProjectPathContainer(), + 'PROJECTCMSROOT' => $this->getProjectCmsPathContainer(), + 'PROJECT_SESSION_HANDLER_ID' => $this->getProjectSessionHandler(), + 'CONSOLE_PATH' => $this->getConsolePath(), // pass the Blackfire env variable here 'BLACKFIRE_CLIENT_ID' => getenv('BLACKFIRE_CLIENT_ID'), 'BLACKFIRE_CLIENT_TOKEN' => getenv('BLACKFIRE_CLIENT_TOKEN'), diff --git a/src/Core/DockerCommand.php b/src/Core/DockerCommand.php index f60c262..bfea5d9 100644 --- a/src/Core/DockerCommand.php +++ b/src/Core/DockerCommand.php @@ -9,6 +9,7 @@ namespace eZ\Launchpad\Core; +use eZ\Launchpad\Configuration\CmsVersionRegistry; use eZ\Launchpad\Core\Client\Docker; use RuntimeException; use Symfony\Component\Console\Input\InputInterface; @@ -33,6 +34,17 @@ abstract class DockerCommand extends Command */ protected $taskExecutor; + /** + * @var CmsVersionRegistry + */ + protected $cmsVersionRegistry; + + public function __construct(CmsVersionRegistry $cmsVersionRegistry) + { + $this->cmsVersionRegistry = $cmsVersionRegistry; + parent::__construct(); + } + protected function configure(): void { $this->addOption('env', 'e', InputOption::VALUE_REQUIRED, 'The Environment name.', 'dev'); @@ -55,6 +67,8 @@ protected function initialize(InputInterface $input, OutputInterface $output): v parent::initialize($input, $output); $this->environment = $input->getOption('env'); $this->projectConfiguration->setEnvironment($this->environment); + $versionConfig = $this->cmsVersionRegistry->getVersion($this->projectConfiguration->get('project.cms_version')); + $fs = new Filesystem(); $currentPwd = $this->projectPath; $provisioningFolder = $this->projectConfiguration->get('provisioning.folder_name'); @@ -74,6 +88,9 @@ protected function initialize(InputInterface $input, OutputInterface $output): v 'project-path' => $this->projectPath, 'provisioning-folder-name' => $provisioningFolder, 'composer-cache-dir' => $this->projectConfiguration->get('docker.host_composer_cache_dir'), + 'project-cms-path-container' => $versionConfig->cmsRoot, + 'project-session-handler' => $versionConfig->sessionHandler, + 'console-path' => $versionConfig->consolePath, ]; $this->dockerClient = new Docker($options, new ProcessRunner(), $this->optimizer); diff --git a/src/Core/ProjectStatusDumper.php b/src/Core/ProjectStatusDumper.php index bd67bb1..232daee 100644 --- a/src/Core/ProjectStatusDumper.php +++ b/src/Core/ProjectStatusDumper.php @@ -91,6 +91,7 @@ protected function dumpComposeCommand(): void protected function dumpServiceAccess(): void { $portPrefix = $this->projectConfiguration->get('docker.network_prefix_port'); + $cmsVersion = $this->projectConfiguration->get('project.cms_version'); $dump = function ($title, $port, $suffix = '', $proto = 'http') use ($portPrefix) { $this->io->writeln( "{$title}: ". @@ -100,9 +101,9 @@ protected function dumpServiceAccess(): void }; $this->io->title('Service Access'); - $adminURI = '/ez'; - if ($this->dockerClient->isEzPlatform2x()) { - $adminURI = '/admin'; + $adminURI = '/admin'; + if (1 === $cmsVersion) { + $adminURI = '/ez'; } $services = $this->projectConfiguration->getDockerCompose()->getServices(); if (isset($services['nginx'])) { diff --git a/src/Core/TaskExecutor.php b/src/Core/TaskExecutor.php index c3a8991..bcb7386 100644 --- a/src/Core/TaskExecutor.php +++ b/src/Core/TaskExecutor.php @@ -173,15 +173,15 @@ public function importData(): Process public function runSymfomyCommand(string $arguments): Process { - $consolePath = $this->dockerClient->isEzPlatform2x() ? 'bin/console' : 'app/console'; + $consolePath = $this->dockerClient->getConsolePath(); - return $this->execute("ezplatform/{$consolePath} {$arguments}"); + return $this->globalExecute("{$consolePath} {$arguments}"); } public function runComposerCommand(string $arguments): Process { return $this->globalExecute( - '/usr/local/bin/composer --working-dir='.$this->dockerClient->getProjectPathContainer().'/ezplatform '. + '/usr/local/bin/composer --working-dir='.$this->dockerClient->getProjectCmsPathContainer().' '. $arguments ); } diff --git a/tests/Tests/Command/TestDockerClient.php b/tests/Tests/Command/TestDockerClient.php index 4c01a2a..b368a43 100644 --- a/tests/Tests/Command/TestDockerClient.php +++ b/tests/Tests/Command/TestDockerClient.php @@ -9,12 +9,19 @@ namespace eZ\Launchpad\Tests\Command; +use eZ\Launchpad\Configuration\CmsVersionRegistry; use eZ\Launchpad\Core\DockerCommand; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; class TestDockerClient extends DockerCommand { + + public function __construct() + { + parent::__construct(new CmsVersionRegistry()); + } + protected function configure(): void { parent::configure(); diff --git a/tests/Tests/Unit/ConfigurationTest.php b/tests/Tests/Unit/ConfigurationTest.php index c37898d..fd5672c 100644 --- a/tests/Tests/Unit/ConfigurationTest.php +++ b/tests/Tests/Unit/ConfigurationTest.php @@ -29,7 +29,10 @@ class ConfigurationTest extends TestCase "provisioning" => [ "folder_name" => "provisioning" ], - "last_update_check" => null + "last_update_check" => null, + "project" => [ + "cms_version" => 'ibexa-4' + ] ]; protected function process($configs): array diff --git a/tests/Tests/Unit/TestCase.php b/tests/Tests/Unit/TestCase.php index 46bdef0..14e4ba6 100644 --- a/tests/Tests/Unit/TestCase.php +++ b/tests/Tests/Unit/TestCase.php @@ -28,18 +28,20 @@ abstract class TestCase extends BaseTestCase protected function setUp(): void { - $this->root = vfsStream::setup('ezlaunchpad'); - $globalConfiguration = vfsStream::url("ezlaunchpad/ez.yml"); - $localConfiguration = vfsStream::url("ezlaunchpad/.ezlaunchpad.yml"); - - file_put_contents( - $globalConfiguration, - ' + $structure = array( + 'provisioning_test' => array( + 'dev' => array( + 'docker-compose-test.yml' => " +version: '2.2' + ", + ), + ), + 'ez.yml' => ' docker: host_machine_mapping: "/Users/plopix/DOCKFILES:/data/DOCKER_SOURCES" host_composer_cache_dir: "/data/DOCKER_SOURCES/.composer_cache" compose_filename: docker-compose-test.yml - + provisioning: folder_name: "provisioning2ouf" @@ -53,20 +55,20 @@ protected function setUp(): void host: plopix.net login: login password: pass - ' - ); - - file_put_contents( - $localConfiguration, - ' + ', + '.ezlaunchpad.yml' => ' last_update_check: 1491955697 +project: + cms_version: ibexa-4 provisioning: folder_name: provisioning_test docker: network_name: newversion_test network_prefix_port: 123 - ' + ' ); + + $this->root = vfsStream::setup('ezlaunchpad', null,$structure); } protected function process($configs): array @@ -113,6 +115,9 @@ public function getDockerClient(bool $hasTty = true): Docker 'network-prefix-port' => 42, 'project-path' => getcwd(), 'provisioning-folder-name' => 'provisioning', + 'project-cms-path-container' => '/var/www/html/project/ibexa', + 'project-session-handler' => 'Ibexa\Bundle\Core\Session\Handler\NativeSessionHandler', + 'console-path' => '/var/www/html/project/ibexa/bin/console' ]; $processRunnerMock = $this->getMockBuilder(ProcessRunner::class)->getMock(); @@ -146,6 +151,9 @@ public function getDockerClientEnvironmentVariables(): array "DEV_GID" => getmygid(), 'COMPOSER_CACHE_DIR' => "/var/www/composer_cache", 'PROJECTMAPPINGFOLDER' => "/var/www/html/project", + 'PROJECTCMSROOT' => '/var/www/html/project/ibexa', + 'PROJECT_SESSION_HANDLER_ID' => 'Ibexa\Bundle\Core\Session\Handler\NativeSessionHandler', + 'CONSOLE_PATH' => '/var/www/html/project/ibexa/bin/console', 'BLACKFIRE_CLIENT_ID' => getenv('BLACKFIRE_CLIENT_ID'), 'BLACKFIRE_CLIENT_TOKEN' => getenv('BLACKFIRE_CLIENT_TOKEN'), 'BLACKFIRE_SERVER_ID' => getenv('BLACKFIRE_SERVER_ID'), @@ -154,7 +162,7 @@ public function getDockerClientEnvironmentVariables(): array 'DOCKER_CERT_PATH' => getenv('DOCKER_CERT_PATH'), 'DOCKER_TLS_VERIFY' => getenv('DOCKER_TLS_VERIFY'), 'PATH' => getenv('PATH'), - 'XDEBUG_ENABLED' => getenv('XDEBUG_ENABLED') === false ? '0' : '1' + 'XDEBUG_ENABLED' => getenv('XDEBUG_ENABLED') === false ? '0' : '1', ]; } }