From 98ce2c29b088183ba5ae38f2967c342503b629ad Mon Sep 17 00:00:00 2001 From: Maciej Kobus Date: Tue, 12 Mar 2024 09:53:52 +0100 Subject: [PATCH 01/32] Created interactive DDEV setup --- .ddev/bin/ibexa-setup.sh | 168 ++++++++++++ .ddev/commands/web/.utils | 92 +++++++ .ddev/commands/web/README.txt | 4 + .ddev/commands/web/gum | 10 + .ddev/commands/web/ibexa-configurator | 365 ++++++++++++++++++++++++++ .ddev/commands/web/ibexa-installer | 131 +++++++++ .ddev/config.db.yaml | 2 + .ddev/config.gum.yaml | 4 + .ddev/config.http.yaml | 1 + .ddev/config.node.yaml | 1 + .ddev/config.php.yaml | 1 + .ddev/config.yaml | 19 ++ .ddev/docker-compose.mounts.yaml | 20 ++ .ddev/web-build/pre.Dockerfile.gum | 5 + 14 files changed, 823 insertions(+) create mode 100755 .ddev/bin/ibexa-setup.sh create mode 100755 .ddev/commands/web/.utils create mode 100755 .ddev/commands/web/README.txt create mode 100755 .ddev/commands/web/gum create mode 100755 .ddev/commands/web/ibexa-configurator create mode 100755 .ddev/commands/web/ibexa-installer create mode 100644 .ddev/config.db.yaml create mode 100644 .ddev/config.gum.yaml create mode 100644 .ddev/config.http.yaml create mode 100644 .ddev/config.node.yaml create mode 100644 .ddev/config.php.yaml create mode 100644 .ddev/config.yaml create mode 100644 .ddev/docker-compose.mounts.yaml create mode 100644 .ddev/web-build/pre.Dockerfile.gum diff --git a/.ddev/bin/ibexa-setup.sh b/.ddev/bin/ibexa-setup.sh new file mode 100755 index 0000000..6f99041 --- /dev/null +++ b/.ddev/bin/ibexa-setup.sh @@ -0,0 +1,168 @@ +#!/bin/bash + +# +# This script reads settings from `ddev ibexa-configurator` and sets up ddev +# + +[ -z "$SETTINGS_FILE" ] && SETTINGS_FILE="./.ddev/.ibexa-instance-settings" +[ -z "$PROVISION_FILE_GENERAL" ] && PROVISION_FILE_GENERAL="./.ddev/.ibexa-setup-general-provisioned" +[ -z "$PROVISION_FILE_SERVICES" ] && PROVISION_FILE_SERVICES="./.ddev/.ibexa-setup-services-provisioned" +[ -z "$VERBOSE_INSTALL" ] && VERBOSE_INSTALL=false + +function verbose_output() { + if [ "$VERBOSE_INSTALL" = true ]; then + "$@" + else + "$@" > /dev/null + fi +} + +if [ "$VERBOSE_INSTALL" != false ] && [ ! -f "$PROVISION_FILE_GENERAL" ] && [ ! -f "$PROVISION_FILE_SERVICES" ]; then + clear +fi + +if [ ! -f "$SETTINGS_FILE" ]; then + echo "Settings file does not exist, run ddev ibexa-configurator first." + exit 1 +fi + +source $SETTINGS_FILE + +if [ ! -f "$PROVISION_FILE_GENERAL" ]; then + # PHP + echo "php_version: $PHP_VERSION" > .ddev/config.php.yaml + echo "πŸ‘· Configured PHP version: $PHP_VERSION" + + # NodeJS + echo "nodejs_version: $NODE_VERSION" > .ddev/config.node.yaml + echo "πŸ‘· Configured Node version: $NODE_VERSION" + + # Web Server + if [ "$HTTP_SERVER" = "apache-fpm" ] + then + echo "webserver_type: $HTTP_SERVER" > .ddev/config.http.yaml + fi + echo "πŸ‘· Configured HTTP server: $HTTP_SERVER" + + # Database + echo "database: + type: $DATABASE + version: $DATABASE_VERSION" > .ddev/config.db.yaml + echo "πŸ‘· Configured Database: $DATABASE:$DATABASE_VERSION" + + # App env + echo "APP_ENV=$APP_ENV" >> .env.local + if [ "$APP_ENV" = "prod" ]; then + echo "APP_DEBUG=0" >> .env.local + else + echo "APP_DEBUG=1" >> .env.local + fi + echo "πŸ‘· Configured app environment: $APP_ENV" + + echo "πŸ‘· Restarting ddev project to reflect webserver and database changes" + + touch "$PROVISION_FILE_GENERAL" + + verbose_output ddev restart +fi + +if [ -f "$PROVISION_FILE_SERVICES" ]; then + exit 0 +fi + +DB_SCHEME=mysql +DB_USER=db +DB_PASS=db +DB_NAME=db +DB_HOST=db +DB_PORT=3306 +DB_VERSION=$DATABASE_VERSION +DB_CHARSET=utf8mb4 +DB_COLLATION=utf8mb4_unicode_520_ci + +if [ "$DATABASE" = "mariadb" ]; then + DB_VERSION=mariadb-`ddev exec -s db mysql -V | awk '{print $5}' | sed 's/-.*//'` +fi + +if [ "$DATABASE" = "postgres" ]; then + DB_PORT=5432 + DB_SCHEME=postgresql + DB_CHARSET=utf8 + DB_COLLATION=utf8_unicode_ci +fi + +echo "# " >> .env.local +echo "# dxp-installer generated" >> .env.local +echo "DATABASE_URL=${DB_SCHEME}://${DB_USER}:${DB_PASS}@${DB_HOST}:${DB_PORT}/${DB_NAME}?serverVersion=${DB_VERSION}&charset=${DB_CHARSET}" >> .env.local +echo "DATABASE_VERSION=${DB_VERSION}" >> .env.local +echo "DATABASE_CHARSET=${DB_CHARSET}" >> .env.local +echo "DATABASE_COLLATION=${DB_COLLATION}" >> .env.local + +echo "πŸ‘· Saved database details in .env.local" + +if [ "$HTTP_CACHE" = "varnish" ]; then + echo "# " >> .env.local + echo "# dxp-installer generated" >> .env.local + echo "TRUSTED_PROXIES=REMOTE_ADDR" >> .env.local + echo "HTTPCACHE_PURGE_TYPE=varnish" >> .env.local + echo "HTTPCACHE_PURGE_SERVER=$DDEV_PRIMARY_URL" >> .env.local + + verbose_output ddev get reithor/ddev-varnish + + # Config file is incorrectly generated, workaround is to hard replace domain name with sed + # Can't use -i option because it's not supported in MacOS + sed 's/VIRTUAL_HOST=novarnish./VIRTUAL_HOST=novarnish.${DDEV_SITENAME}/g' .ddev/docker-compose.varnish-extras.yaml > .ddev/varnish.temp + rm .ddev/docker-compose.varnish-extras.yaml + mv .ddev/varnish.temp .ddev/docker-compose.varnish-extras.yaml +fi + +echo "πŸ‘· Configured HTTP cache: $HTTP_CACHE" + +# Memcached +if [ "$APP_CACHE" = "memcached" ]; then + echo "# " >> .env.local + echo "# dxp-installer generated" >> .env.local + echo "CACHE_POOL=\"cache.memcached\"" >> .env.local + echo "CACHE_DSN=\"memcached:11211?weight=33\"" >> .env.local + + verbose_output ddev get ddev/ddev-memcached +fi + +# Redis +if [ "$APP_CACHE" = "redis" ]; then + echo "# " >> .env.local + echo "# dxp-installer generated" >> .env.local + echo "CACHE_POOL=cache.redis" >> .env.local + echo "CACHE_DSN=redis:6379" >> .env.local + + verbose_output ddev get ddev/ddev-redis-7 +fi + +echo "πŸ‘· Configured app cache: $APP_CACHE" + +# Solr +if [ "$SEARCH_ENGINE" = "solr" ]; then + echo "# " >> .env.local + echo "# dxp-installer generated" >> .env.local + echo "SEARCH_ENGINE=solr" >> .env.local + echo "SOLR_CORE=collection1" >> .env.local + echo "SOLR_DSN=http://solr:8983/solr" >> .env.local + + verbose_output ddev get reithor/ddev-ibexa-solr +fi + +# Elasticsearch +if [ "$SEARCH_ENGINE" = "elasticsearch" ]; then + echo "# " >> .env.local + echo "# dxp-installer generated" >> .env.local + echo "SEARCH_ENGINE=elasticsearch" >> .env.local + echo "ELASTICSEARCH_DSN=http://elasticsearch:9200" >> .env.local + + verbose_output ddev get ddev/ddev-elasticsearch +fi + +echo "πŸ‘· Configured search engine: $SEARCH_ENGINE" + +echo "βœ… Finished setting up ddev services. Restarting the environment..." +touch "$PROVISION_FILE_SERVICES" +ddev restart diff --git a/.ddev/commands/web/.utils b/.ddev/commands/web/.utils new file mode 100755 index 0000000..9ad718e --- /dev/null +++ b/.ddev/commands/web/.utils @@ -0,0 +1,92 @@ +#!/bin/bash + +# +# Default settings +# + +export PRIMARY_COLOR="#FF4713" +export GUM_SPIN_SPINNER_FOREGROUND="$PRIMARY_COLOR" +export GUM_CHOOSE_HEADER_FOREGROUND="$PRIMARY_COLOR" +export BORDER_FOREGROUND="$PRIMARY_COLOR" +export CLI_WIDTH=90 +export IBEXA_DXP_INSTALLED_LOCK_FILE=".ddev/.ibexa-dxp-installed" +export INSTANCE_SETTINGS_FILE=".ddev/.ibexa-instance-settings" + +# +# Helper functions +# + +function bold() { + gum style --bold "$@" +} + +function italic() { + gum style --italic "$@" +} + +function underline() { + gum style --underline "$@" +} + +function faint() { + gum style --faint "$@" +} + +function choose() { + local HEADER="$1" + shift + SELECT=$(gum choose --header "$HEADER" -- "$@") +} + +function execute_with_spinner() { + TITLE="$1" + shift + + if [ "$VERBOSE_INSTALL" = true ]; then + "$@" + else + gum spin --title "$TITLE" --timeout 0 -- "$@" + fi +} + +function banner() { + gum style \ + --foreground "#FF4713" \ + --align center --width 90 \ + "" \ + ":::: ./. '..-..' ''...'' .....' '....' " \ + "oo+/ ./++:/++++++++/:. .:/++//////:. -////:' '-://///////-' " \ + "o/. /++++++/:---:++++/' '/+++/:----/////- -////:' -/////:--::////:' " \ + " . /++++:' ./+++. .+++/. .:///:''-' -////:' ////-' '-////' " \ + " ./+ /+++: '+++/ +++/' .////:' :///////:' -///. .///:" \ + "/o++ /+++. :+++''+++: .////:' .//////. :/// ////" \ + "oo++ -+++: '+++/ /++/'./+//:' '-////////:' -///. '////" \ + "oo++ /+++/. -++++. .+++++++:' .:////-''-////:' '////- ./////" \ + "oo++ :+++++::::/++++/' ./++++/---://///-' '-////:' -////:----:///////" \ + "oo++ '-/++++++++/:. .:/++//////:. '-////:' '-://///////-///." \ + "... '....'' '.....' ''''' '....' :. " + + gum style \ + --foreground "#FFFFFF" --faint --align center --width 90 \ + "" \ + "~==[ $1 ]==~" \ + "" +} + +# +# Custom error handling +# --- +# Exits on all errors occurred during runtime +# + +# Immediately stop the execution on error +set -e + +function error_handler() { + echo "" + echo "❌️ An error occurred. Exiting..." + exit 1 +} + +# Set custom error handler +trap 'error_handler' ERR diff --git a/.ddev/commands/web/README.txt b/.ddev/commands/web/README.txt new file mode 100755 index 0000000..e0c4a05 --- /dev/null +++ b/.ddev/commands/web/README.txt @@ -0,0 +1,4 @@ +#ddev-generated +Scripts in this directory will be executed inside the web container. + +See https://ddev.readthedocs.io/en/stable/users/extend/custom-commands/#environment-variables-provided for a list of environment variables that can be used in the scripts. diff --git a/.ddev/commands/web/gum b/.ddev/commands/web/gum new file mode 100755 index 0000000..84afe38 --- /dev/null +++ b/.ddev/commands/web/gum @@ -0,0 +1,10 @@ +#!/bin/bash + +#ddev-generated +## Description: Run gum in the web container +## Usage: gum +## Example: "ddev gum" +## ExecRaw: true +## HostWorkingDir: true + +gum "$@" diff --git a/.ddev/commands/web/ibexa-configurator b/.ddev/commands/web/ibexa-configurator new file mode 100755 index 0000000..8f39d52 --- /dev/null +++ b/.ddev/commands/web/ibexa-configurator @@ -0,0 +1,365 @@ +#!/bin/bash + +## #ddev-generated +## Description: Runs service configurator +## Usage: ibexa-configurator +## Example: ddev ibexa-configurator + +source .ddev/commands/web/.utils + +# +# Default settings +# + +LABEL_INSTALL_SAMPLE_DATA="Yes" +LABEL_INSTALL_PROFILER="Yes" +IBEXA_DXP_PRODUCTS=("oss" "headless" "experience" "commerce") + +[ -z "$PHP_VERSION" ] && PHP_VERSION="8.3" +[ -z "$DATABASE" ] && DATABASE="mariadb" +[ -z "$DATABASE_VERSION" ] && DATABASE_VERSION="10.11" +[ -z "$NODE_VERSION" ] && NODE_VERSION="20" +[ -z "$HTTP_CACHE" ] && HTTP_CACHE="varnish" +[ -z "$HTTP_SERVER" ] && HTTP_SERVER="nginx-fpm" +[ -z "$APP_CACHE" ] && APP_CACHE="redis" +[ -z "$SEARCH_ENGINE" ] && SEARCH_ENGINE="elasticsearch" +[ -z "$INSTALL_SAMPLE_DATA" ] && INSTALL_SAMPLE_DATA=true +[ -z "$INSTALL_PROFILER" ] && INSTALL_PROFILER=true +[ -z "$APP_ENV" ] && APP_ENV="prod" +[ -z "$INSTALL_CLOUD_CONFIG" ] && INSTALL_CLOUD_CONFIG=true + +if [ -f "$INSTANCE_SETTINGS_FILE" ]; then + # Nothing to do + exit 0 +fi + +function detect_version() { + if [ "$DXP_EDITION" != "website" ] && [ -f composer.lock ]; then + MIN_STABILITY="`(jq -r '."minimum-stability"' composer.lock)`" + PRODUCT_VERSION="`(jq -r '.packages[] | select(.name == "ibexa/oss") | .version' composer.lock | sed 's/^v//')`" + else + MIN_STABILITY="`(jq -r '."minimum-stability"' composer.json)`" + PRODUCT_VERSION="`(jq -r '.extra."branch-alias"."dev-main"' composer.json)`" + fi +} + +function detect_product() { + PROJECT_NAME=$(jq -r '.name' composer.json) + # Strip "ibexa/" and "-skeleton" parts from the value + DXP_EDITION=$(echo $PROJECT_NAME | sed 's/ibexa\///;s/-skeleton//') + case "$DXP_EDITION" in + "commerce") + PRODUCT_TYPE="Ibexa DXP Commerce" + ;; + "experience") + PRODUCT_TYPE="Ibexa DXP Experience" + ;; + "headless") + PRODUCT_TYPE="Ibexa DXP Headless" + ;; + "oss") + PRODUCT_TYPE="Ibexa OSS" + ;; + esac +} + +function configure_product() { + if [ "$DXP_EDITION" = "website" ]; then + choose "`(faint "[Product]")` `(bold "Select Ibexa product")`" "Ibexa OSS" "Ibexa DXP Headless" "Ibexa DXP Experience" "Ibexa DXP Commerce" + PRODUCT_TYPE="$SELECT" + case "$SELECT" in + "Ibexa DXP Commerce") + DXP_EDITION=commerce + ;; + "Ibexa DXP Experience") + DXP_EDITION=experience + ;; + "Ibexa DXP Headless") + DXP_EDITION=headless + ;; + "Ibexa OSS") + DXP_EDITION=oss + ;; + esac + fi +} + +function configure_php() { + choose "`(faint "[Setup]")` `(bold "Select PHP version")`" "8.3 (recommended)" "8.2" "8.1" + case "$SELECT" in + "8.3 (recommended)") + PHP_VERSION="8.3" + ;; + "8.2") + PHP_VERSION="8.2" + ;; + "8.1") + PHP_VERSION="8.1" + ;; + esac +} + +function configure_node() { + choose "`(faint "[Setup]")` `(bold "Select Node version")`" "20 (recommended)" "18" "21" "22" + case "$SELECT" in + "20 (recommended)") + NODE_VERSION="20" + ;; + "18") + NODE_VERSION="18" + ;; + "21") + NODE_VERSION="21" + ;; + "22") + NODE_VERSION="22" + ;; + esac +} + +function configure_http_server() { + choose "`(faint "[Setup]")` `(bold "Select HTTP server")`" "nginx (recommended)" "Apache" + case "$SELECT" in + "nginx (recommended)") + HTTP_SERVER="nginx-fpm" + ;; + "Apache") + HTTP_SERVER="apache-fpm" + ;; + esac +} + +function configure_http_cache() { + choose "`(faint "[Setup]")` `(bold "Select HTTP cache")`" "Varnish (recommended)" "Symfony" + case "$SELECT" in + "Varnish (recommended)") + HTTP_CACHE="varnish" + ;; + "Symfony") + HTTP_CACHE="symfony" + ;; + esac +} + +function configure_database() { + choose "`(faint "[Setup]")` `(bold "Select database platform")`" "MariaDB (recommended)" "MySQL" "PostgreSQL" + case "$SELECT" in + "MariaDB (recommended)") + DATABASE="mariadb" + configure_mariadb_version + ;; + "MySQL") + DATABASE="mysql" + DATABASE_VERSION="8.0" + ;; + "PostgreSQL") + DATABASE="postgres" + configure_postgres_version + ;; + esac +} + +function configure_mariadb_version() { + choose "`(faint "[Setup]")` `(bold "Select MariaDB version")`" "10.11 (recommended)" "10.3" + case "$SELECT" in + "10.11 (recommended)") + DATABASE_VERSION="10.11" + ;; + "10.3") + DATABASE_VERSION="10.3" + ;; + esac +} + +function configure_postgres_version() { + choose "`(faint "[Setup]")` `(bold "Select PostgreSQL version")`" "16 (recommended)" "15" "14" "13" "12" "11" "10" + case "$SELECT" in + "16 (recommended)") + DATABASE_VERSION="16" + ;; + "15") + DATABASE_VERSION="15" + ;; + "14") + DATABASE_VERSION="14" + ;; + "13") + DATABASE_VERSION="13" + ;; + "12") + DATABASE_VERSION="12" + ;; + "11") + DATABASE_VERSION="11" + ;; + "10") + DATABASE_VERSION="10" + ;; + esac +} + +function configure_app_cache() { + choose "`(faint "[Setup]")` `(bold "Select application cache")`" "Redis (recommended)" "Memcached" "Filesystem" + case "$SELECT" in + "Redis (recommended)") + APP_CACHE="redis" + ;; + "Memcached") + APP_CACHE="memcached" + ;; + "Filesystem") + APP_CACHE="filesystem" + ;; + esac +} + +function configure_search_engine() { + choose "`(faint "[Setup]")` `(bold "Select search engine")`" "Elasticsearch (recommended)" "Solr" "Legacy" + case "$SELECT" in + "Elasticsearch (recommended)") + SEARCH_ENGINE="elasticsearch" + ;; + "Solr") + SEARCH_ENGINE="solr" + ;; + "Legacy") + SEARCH_ENGINE="legacy" + ;; + esac +} + +function configure_sample_data() { + if [ "$DXP_EDITION" != "oss" ]; then + choose "`(faint "[Instance]")` `(bold "Install sample data?")`" "Yes (recommended)" "No" + case "$SELECT" in + "Yes (recommended)") + INSTALL_SAMPLE_DATA=true + LABEL_INSTALL_SAMPLE_DATA="Yes" + ;; + "No") + INSTALL_SAMPLE_DATA=false + LABEL_INSTALL_SAMPLE_DATA="No" + ;; + esac + else + # OSS is incompatible with ibexa/test-fixtures + INSTALL_SAMPLE_DATA=false + LABEL_INSTALL_SAMPLE_DATA="No" + fi +} + +function configure_profiler() { + choose "`(faint "[Instance]")` `(bold "Install Symfony profiler?")`" "No (recommended)" "Yes" + case "$SELECT" in + "No (recommended)") + INSTALL_PROFILER=false + LABEL_INSTALL_PROFILER="No" + ;; + "Yes") + INSTALL_PROFILER=true + LABEL_INSTALL_PROFILER="Yes" + ;; + esac +} + +function configure_app_env() { + choose "`(faint "[Instance]")` `(bold "Select app environment")`" "prod (recommended)" "dev" + case "$SELECT" in + "prod (recommended)") + APP_ENV=prod + ;; + "dev") + APP_ENV=dev + ;; + esac +} + +function configure_cloud() { + choose "`(faint "[Instance]")` `(bold "Install Ibexa Cloud configuration?")`" "Yes (recommended)" "No" + case "$SELECT" in + "Yes (recommended)") + INSTALL_CLOUD_CONFIG=true + ;; + "No") + INSTALL_CLOUD_CONFIG=false + ;; + esac +} + +function print_selected_settings() { + echo "${1}" # print title + + echo "$PHP_VERSION,$NODE_VERSION,$HTTP_SERVER,$HTTP_CACHE,$DATABASE ($DATABASE_VERSION),$APP_CACHE,$SEARCH_ENGINE,$LABEL_INSTALL_SAMPLE_DATA" \ + | gum table --print --columns "PHP,Node,Server,HTTP Cache,Database,Cache,Search engine,Sample data" + + echo "" +} + +function select_configuration() { + configure_php + configure_node + configure_http_server + configure_http_cache + configure_database + configure_app_cache + configure_search_engine + configure_sample_data + configure_profiler + configure_app_env + configure_cloud + + print_selected_settings "`gum style --bold --underline -- "Your configuration:"`" + + if ! gum confirm "Confirm these settings?" ; + then + select_configuration + fi +} + +function save_changes() { + touch "$INSTANCE_SETTINGS_FILE" + + echo "DXP_EDITION=\"$DXP_EDITION\"" >> $INSTANCE_SETTINGS_FILE + echo "PRODUCT_TYPE=\"$PRODUCT_TYPE\"" >> $INSTANCE_SETTINGS_FILE + echo "PRODUCT_VERSION=\"$PRODUCT_VERSION\"" >> $INSTANCE_SETTINGS_FILE + echo "PHP_VERSION=\"$PHP_VERSION\"" >> $INSTANCE_SETTINGS_FILE + echo "NODE_VERSION=\"$NODE_VERSION\"" >> $INSTANCE_SETTINGS_FILE + echo "DATABASE=\"$DATABASE\"" >> $INSTANCE_SETTINGS_FILE + echo "DATABASE_VERSION=\"$DATABASE_VERSION\"" >> $INSTANCE_SETTINGS_FILE + echo "HTTP_CACHE=\"$HTTP_CACHE\"" >> $INSTANCE_SETTINGS_FILE + echo "APP_CACHE=\"$APP_CACHE\"" >> $INSTANCE_SETTINGS_FILE + echo "SEARCH_ENGINE=\"$SEARCH_ENGINE\"" >> $INSTANCE_SETTINGS_FILE + echo "INSTALL_SAMPLE_DATA=$INSTALL_SAMPLE_DATA" >> $INSTANCE_SETTINGS_FILE + echo "INSTALL_PROFILER=$INSTALL_PROFILER" >> $INSTANCE_SETTINGS_FILE + echo "APP_ENV=\"$APP_ENV\"" >> $INSTANCE_SETTINGS_FILE + echo "HTTP_SERVER=\"$HTTP_SERVER\"" >> $INSTANCE_SETTINGS_FILE + echo "INSTALL_CLOUD_CONFIG=$INSTALL_CLOUD_CONFIG" >> $INSTANCE_SETTINGS_FILE +} + +# +# Main +# + +clear + +banner "Interactive Installation Tool" + +bold "⚠️ This tool is experimental. Do not use on production servers." +echo "" + +detect_product +detect_version + +configure_product + +print_selected_settings "`gum style --bold --underline -- "Recommended configuration:"`" + +if ! gum confirm "Do you confirm these settings?" ; +then + select_configuration +fi + +save_changes + + + diff --git a/.ddev/commands/web/ibexa-installer b/.ddev/commands/web/ibexa-installer new file mode 100755 index 0000000..1c16cc8 --- /dev/null +++ b/.ddev/commands/web/ibexa-installer @@ -0,0 +1,131 @@ +#!/bin/bash + +## #ddev-generated +## Description: Runs interactive installer for Ibexa DXP +## Usage: ibexa-installer +## Example: ddev ibexa-installer + +source .ddev/commands/web/.utils + +if [ -f "$IBEXA_DXP_INSTALLED_LOCK_FILE" ] || [ ! -f "$INSTANCE_SETTINGS_FILE" ] +then + # Nothing to do + exit 0 +fi + +source "$INSTANCE_SETTINGS_FILE" + +# +# Default settings +# + +ADMIN_USERNAME=admin +ADMIN_PASSWORD=publish + +# +# Main +# + +if [ "$VERBOSE_INSTALL" = false ]; then + clear +fi + +# Workaround to the issue on Mac OS +git config --global --add safe.directory /var/www/html + +banner "Interactive Installation Tool" + +echo "πŸš€ Installing `(bold "$PRODUCT_TYPE v$PRODUCT_VERSION")`" + +if [ "$DXP_EDITION" != "oss" ] || [ "$INSTALL_SAMPLE_DATA" = true ]; then + echo "Adding updates.ibexa.co repository to composer.json" + echo "You might be prompted for repository credentials during installation" + execute_with_spinner "Updating composer.json..." composer config repositories.ibexa composer https://updates.ibexa.co +fi + +composer config extra.runtime.error_handler "\\Ibexa\\Contracts\\Core\\MVC\\Symfony\\ErrorHandler\\Php82HideDeprecationsErrorHandler" + +execute_with_spinner "Installing ibexa/${DXP_EDITION} package..." composer require "ibexa/$DXP_EDITION:$PRODUCT_VERSION" -W --no-scripts --no-interaction +echo "βœ… Package ibexa/${DXP_EDITION} installed successfully" + +execute_with_spinner "Initializing git repository..." git init > /dev/null && git add . > /dev/null && git commit -m "Installed Ibexa DXP" > /dev/null +echo "βœ… Initialized git repository" + +execute_with_spinner "Installing Flex recipe..." composer recipes:install ibexa/${DXP_EDITION} --force --reset +echo "βœ… Installed Flex recipe" + +# Install test fixtures +if [ "$INSTALL_SAMPLE_DATA" = true ]; then + execute_with_spinner "Installing ibexa/test-fixtures package" composer require ibexa/test-fixtures:"$PRODUCT_VERSION" --no-scripts --no-interaction + echo "βœ… Installed ibexa/test-fixtures package" +fi + +# Install profiler +if [ "$INSTALL_PROFILER" = true ]; then + execute_with_spinner "Installing Symfony Profiler" composer require symfony/profiler-pack --no-scripts --no-interaction + echo "βœ… Installed Symfony Profiler" +fi + +execute_with_spinner "Running Composer scripts..." composer run post-update-cmd +echo "βœ… Scripts finished successfully" + +#execute_with_spinner "Dropping database for fresh install" php bin/console doctrine:database:drop --force +#echo "βœ… Database dropped" +# +#execute_with_spinner "Removing existing migrations" rm -rf src/Migrations/Ibexa +#echo "βœ… Migrations removed" +# +#execute_with_spinner "Clearing cache" php bin/console c:c --env=prod +#echo "βœ… Cache cleared" + +execute_with_spinner "Installing database..." php bin/console ibexa:install +echo "βœ… Database installed" + +if [ "$SEARCH_ENGINE" = "solr" ] || [ "$SEARCH_ENGINE" = "elasticsearch" ]; then + if [ "$SEARCH_ENGINE" = "elasticsearch" ]; then + execute_with_spinner "Putting Elasticsearch index template" php bin/console ibexa:elasticsearch:put-index-template + echo "βœ… Put Elasticsearch index template" + fi + execute_with_spinner "Reindexing search data" php bin/console ibexa:reindex + echo "βœ… Reindexed search data" +fi + +# Setup sample data +if [ "$INSTALL_SAMPLE_DATA" = true ]; then + execute_with_spinner "Installing sample data" php bin/console ibexa:test-fixtures:setup + echo "βœ… Installed sample data" +fi + +execute_with_spinner "Generating GraphQL schema" php bin/console ibexa:graphql:generate-schema +echo "βœ… GraphQL schema generated" + +# Setup Ibexa Cloud +if [ "$INSTALL_CLOUD_CONFIG" = true ]; then + execute_with_spinner "Installing Ibexa Cloud configuration" composer ibexa:setup --platformsh + echo "βœ… Installed Ibexa Cloud configuration" +fi + +echo "βœ… All done! You can now access your new project using provided details:" + +gum style --border double --margin "1 1" --padding "1 1" --width 60 \ + "Website: ` bold --bold "$DDEV_PRIMARY_URL" `" \ + "Backoffice: ` bold --bold "$DDEV_PRIMARY_URL/admin" `" \ + "" \ + "Username: ` bold "admin" `" \ + "Password: ` bold "publish" `" \ + "" \ + "Run `(bold "ddev describe")` for more details" + +echo "πŸ“§ Run `(bold "ddev mailpit")` to launch Mailpit interface and see catched e-mails" +echo "πŸ—„οΈ Run `(bold "ddev get ddev/ddev-phpmyadmin")` to install PHPMyAdmin" +echo "πŸ—„οΈ Run `(bold "ddev querious|sequelace|tableplus|dbeaver")` to launch database client apps" +echo "" +echo "πŸ“¦οΈ Run `(bold "ddev composer ...")` to execute Composer commands" +echo "🐘️ Run `(bold "ddev php ...")` to execute PHP scripts" +echo "🐞️ Run `(bold "ddev xdebug on|off")` to control Xdebug" +echo "" +echo "πŸš€οΈ Run `(bold "ddev start")` to start containers" +echo "⛔️ Run `(bold "ddev stop")` to stop containers" +echo "πŸ”„οΈ Run `(bold "ddev restart")` to restart containers" + +echo "`date`" > ./.ddev/.ibexa-dxp-installed diff --git a/.ddev/config.db.yaml b/.ddev/config.db.yaml new file mode 100644 index 0000000..1a4c2c0 --- /dev/null +++ b/.ddev/config.db.yaml @@ -0,0 +1,2 @@ +omit_containers: + - db diff --git a/.ddev/config.gum.yaml b/.ddev/config.gum.yaml new file mode 100644 index 0000000..e814026 --- /dev/null +++ b/.ddev/config.gum.yaml @@ -0,0 +1,4 @@ +#ddev-generated +webimage_extra_packages: [gum] +web_environment: + - COLORTERM=${COLORTERM} diff --git a/.ddev/config.http.yaml b/.ddev/config.http.yaml new file mode 100644 index 0000000..199c894 --- /dev/null +++ b/.ddev/config.http.yaml @@ -0,0 +1 @@ +webserver_type: "nginx-fpm" diff --git a/.ddev/config.node.yaml b/.ddev/config.node.yaml new file mode 100644 index 0000000..aba6299 --- /dev/null +++ b/.ddev/config.node.yaml @@ -0,0 +1 @@ +nodejs_version: "20" diff --git a/.ddev/config.php.yaml b/.ddev/config.php.yaml new file mode 100644 index 0000000..864a10e --- /dev/null +++ b/.ddev/config.php.yaml @@ -0,0 +1 @@ +php_version: "8.3" diff --git a/.ddev/config.yaml b/.ddev/config.yaml new file mode 100644 index 0000000..649d994 --- /dev/null +++ b/.ddev/config.yaml @@ -0,0 +1,19 @@ +type: php +composer_version: "2" +nodejs_version: "18" +router_http_port: "80" +router_https_port: "443" +docroot: "public/" +use_dns_when_possible: true +additional_hostnames: [] +additional_fqdns: [] +xdebug_enabled: false +upload_dirs: + - var/storage +web_environment: + - VERBOSE_INSTALL=false # set to `true` to view verbose output during install +hooks: + post-start: + - exec-host: "ddev ibexa-configurator" + - exec-host: "./.ddev/bin/ibexa-setup.sh" + - exec-host: "ddev ibexa-installer" diff --git a/.ddev/docker-compose.mounts.yaml b/.ddev/docker-compose.mounts.yaml new file mode 100644 index 0000000..9562408 --- /dev/null +++ b/.ddev/docker-compose.mounts.yaml @@ -0,0 +1,20 @@ +#services: +# web: +# volumes: +# - "~/Projects/Web/ibexa/core:/var/www/html/vendor/ibexa/core:ro" + +# +# If you are using Mutagen, you also need to modify .ddev/mutagen/mutagen.yml file. +# Remove first line containing "#ddev-generated" and add container paths to the list. +# +# Example: +# +# sync: +# defaults: +# (...) +# ignore: +# paths: +# - ".idea" +# - "/public/var/storage" +# - "/vendor/ibexa/core" # Added new path +# \ No newline at end of file diff --git a/.ddev/web-build/pre.Dockerfile.gum b/.ddev/web-build/pre.Dockerfile.gum new file mode 100644 index 0000000..390b8b8 --- /dev/null +++ b/.ddev/web-build/pre.Dockerfile.gum @@ -0,0 +1,5 @@ +#ddev-generated +# https://github.com/charmbracelet/gum#installation +RUN mkdir -p /etc/apt/keyrings +RUN curl -fsSL https://repo.charm.sh/apt/gpg.key | gpg --dearmor -o /etc/apt/keyrings/charm.gpg +RUN echo "deb [signed-by=/etc/apt/keyrings/charm.gpg] https://repo.charm.sh/apt/ * *" | tee /etc/apt/sources.list.d/charm.list From 489a53ad0ba9756b6f5da1e7c152203985bc8c8d Mon Sep 17 00:00:00 2001 From: Maciej Kobus Date: Fri, 10 May 2024 12:34:57 +0200 Subject: [PATCH 02/32] Updated Ibexa banner --- .ddev/commands/web/.utils | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/.ddev/commands/web/.utils b/.ddev/commands/web/.utils index 9ad718e..b1df791 100755 --- a/.ddev/commands/web/.utils +++ b/.ddev/commands/web/.utils @@ -52,23 +52,25 @@ function execute_with_spinner() { function banner() { gum style \ --foreground "#FF4713" \ - --align center --width 90 \ - "" \ - ":::: ./. '..-..' ''...'' .....' '....' " \ - "oo+/ ./++:/++++++++/:. .:/++//////:. -////:' '-://///////-' " \ - "o/. /++++++/:---:++++/' '/+++/:----/////- -////:' -/////:--::////:' " \ - " . /++++:' ./+++. .+++/. .:///:''-' -////:' ////-' '-////' " \ - " ./+ /+++: '+++/ +++/' .////:' :///////:' -///. .///:" \ - "/o++ /+++. :+++''+++: .////:' .//////. :/// ////" \ - "oo++ -+++: '+++/ /++/'./+//:' '-////////:' -///. '////" \ - "oo++ /+++/. -++++. .+++++++:' .:////-''-////:' '////- ./////" \ - "oo++ :+++++::::/++++/' ./++++/---://///-' '-////:' -////:----:///////" \ - "oo++ '-/++++++++/:. .:/++//////:. '-////:' '-://///////-///." \ - "... '....'' '.....' ''''' '....' :. " + --align center --width 90 \ + "" \ + "#%%* =# " \ + "%%%+ -#%% " \ + "%#- #%%% " \ + ". . #%%% .... ... ..... ... " \ + " :** #%%%:+#%%%%%%#+: -+#%%%%%#+- -#%%%*. :=*%%%%%%#+- " \ + "+%%* #%%%%%%#*+++#%%%#- +%%%%#+++*%%%%+. :#%%%*: :*%%%%**+*#%%%%= " \ + "%%%* #%%%%+. .=%%%* .#%%#= .+%%%*..: -#%%%+: =%%%*: .+%%%# " \ + "%%%* #%%%- :%%%= *%%%. .+%%%*:.*%%*#%%%*. :%%%= :%%%+" \ + "%%%* #%%% #%%* %%%+ .+%%%*: -%%%%%#: +%%% *%%%" \ + "%%%* +%%%. %%%+ #%%# .+%%%*: -#%%%%%%*: =%%%. #%%%" \ + "%%%* .%%%#: .#%%#. -%%%*%%%*- -#%%%*:-*%%%*: #%%#: .*%%%%" \ + "%%%* :#%%%*=::.:=*%%%#. -%%%%%*:.:-+%%%%*. :*%%%*: *%%%*-:...-+%%%%%%" \ + "%%%* -*%%%%%%%%%%*- .=#%%%%%%%%%#+. -#%%%*: :*%%%%%%%%%%##%%=" \ + "" gum style \ --foreground "#FFFFFF" --faint --align center --width 90 \ - "" \ "~==[ $1 ]==~" \ "" } From 8ab8240bf58ee71da8daf858cff2e714f2d9f524 Mon Sep 17 00:00:00 2001 From: Maciej Kobus Date: Tue, 11 Jun 2024 13:29:38 +0200 Subject: [PATCH 03/32] Made ibexa-setup.sh to ddev host script --- .ddev/{bin/ibexa-setup.sh => commands/host/ibexa-setup} | 7 ++++--- .ddev/config.yaml | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) rename .ddev/{bin/ibexa-setup.sh => commands/host/ibexa-setup} (96%) diff --git a/.ddev/bin/ibexa-setup.sh b/.ddev/commands/host/ibexa-setup similarity index 96% rename from .ddev/bin/ibexa-setup.sh rename to .ddev/commands/host/ibexa-setup index 6f99041..882efd8 100755 --- a/.ddev/bin/ibexa-setup.sh +++ b/.ddev/commands/host/ibexa-setup @@ -1,8 +1,9 @@ #!/bin/bash -# -# This script reads settings from `ddev ibexa-configurator` and sets up ddev -# +## #ddev-generated +## Description: This script reads settings from `ddev ibexa-configurator` and sets up ddev +## Usage: ibexa-setup +## Example: ddev ibexa-setup [ -z "$SETTINGS_FILE" ] && SETTINGS_FILE="./.ddev/.ibexa-instance-settings" [ -z "$PROVISION_FILE_GENERAL" ] && PROVISION_FILE_GENERAL="./.ddev/.ibexa-setup-general-provisioned" diff --git a/.ddev/config.yaml b/.ddev/config.yaml index 649d994..fa97fd1 100644 --- a/.ddev/config.yaml +++ b/.ddev/config.yaml @@ -15,5 +15,5 @@ web_environment: hooks: post-start: - exec-host: "ddev ibexa-configurator" - - exec-host: "./.ddev/bin/ibexa-setup.sh" + - exec-host: "ddev ibexa-setup" - exec-host: "ddev ibexa-installer" From e888014dbeb5ca8fc681a4114d346930fd6ecc8c Mon Sep 17 00:00:00 2001 From: Maciej Kobus Date: Tue, 11 Jun 2024 14:48:22 +0200 Subject: [PATCH 04/32] Set terminal colors independent from host --- .ddev/config.gum.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ddev/config.gum.yaml b/.ddev/config.gum.yaml index e814026..cd60a9e 100644 --- a/.ddev/config.gum.yaml +++ b/.ddev/config.gum.yaml @@ -1,4 +1,4 @@ #ddev-generated webimage_extra_packages: [gum] web_environment: - - COLORTERM=${COLORTERM} + - COLORTERM=truecolor From 50f7de5ee8886d0c958ba48f8a5f93e3b6b67b0c Mon Sep 17 00:00:00 2001 From: Maciej Kobus Date: Tue, 11 Jun 2024 14:48:36 +0200 Subject: [PATCH 05/32] Use `ibexa/ddev-solr` addon --- .ddev/commands/host/ibexa-setup | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ddev/commands/host/ibexa-setup b/.ddev/commands/host/ibexa-setup index 882efd8..06edc47 100755 --- a/.ddev/commands/host/ibexa-setup +++ b/.ddev/commands/host/ibexa-setup @@ -149,7 +149,7 @@ if [ "$SEARCH_ENGINE" = "solr" ]; then echo "SOLR_CORE=collection1" >> .env.local echo "SOLR_DSN=http://solr:8983/solr" >> .env.local - verbose_output ddev get reithor/ddev-ibexa-solr + verbose_output ddev get ibexa/ddev-solr fi # Elasticsearch From d80eb7ca799d28e2fc3998caca42cde1c483063a Mon Sep 17 00:00:00 2001 From: Maciej Kobus Date: Tue, 11 Jun 2024 14:50:45 +0200 Subject: [PATCH 06/32] Fixed Redis 7 setup --- .ddev/commands/host/ibexa-setup | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.ddev/commands/host/ibexa-setup b/.ddev/commands/host/ibexa-setup index 06edc47..e0e04e5 100755 --- a/.ddev/commands/host/ibexa-setup +++ b/.ddev/commands/host/ibexa-setup @@ -134,9 +134,13 @@ if [ "$APP_CACHE" = "redis" ]; then echo "# " >> .env.local echo "# dxp-installer generated" >> .env.local echo "CACHE_POOL=cache.redis" >> .env.local - echo "CACHE_DSN=redis:6379" >> .env.local + echo "CACHE_DSN=redis@redis:6379" >> .env.local verbose_output ddev get ddev/ddev-redis-7 + + echo "# " >> .ddev/redis/memory.conf + echo "# dxp-installer generated" >> .ddev/redis/memory.conf + echo "maxmemory-policy volatile-lfu" >> .ddev/redis/memory.conf fi echo "πŸ‘· Configured app cache: $APP_CACHE" From 04170808a428de69c196b05e112852557a09af1d Mon Sep 17 00:00:00 2001 From: Maciej Kobus Date: Tue, 11 Jun 2024 14:51:01 +0200 Subject: [PATCH 07/32] Removed workaround for Varnish setup --- .ddev/commands/host/ibexa-setup | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/.ddev/commands/host/ibexa-setup b/.ddev/commands/host/ibexa-setup index e0e04e5..bdb20b6 100755 --- a/.ddev/commands/host/ibexa-setup +++ b/.ddev/commands/host/ibexa-setup @@ -30,6 +30,9 @@ fi source $SETTINGS_FILE if [ ! -f "$PROVISION_FILE_GENERAL" ]; then + # Project name + ddev config --project-name="$DDEV_SITENAME" + # PHP echo "php_version: $PHP_VERSION" > .ddev/config.php.yaml echo "πŸ‘· Configured PHP version: $PHP_VERSION" @@ -109,12 +112,6 @@ if [ "$HTTP_CACHE" = "varnish" ]; then echo "HTTPCACHE_PURGE_SERVER=$DDEV_PRIMARY_URL" >> .env.local verbose_output ddev get reithor/ddev-varnish - - # Config file is incorrectly generated, workaround is to hard replace domain name with sed - # Can't use -i option because it's not supported in MacOS - sed 's/VIRTUAL_HOST=novarnish./VIRTUAL_HOST=novarnish.${DDEV_SITENAME}/g' .ddev/docker-compose.varnish-extras.yaml > .ddev/varnish.temp - rm .ddev/docker-compose.varnish-extras.yaml - mv .ddev/varnish.temp .ddev/docker-compose.varnish-extras.yaml fi echo "πŸ‘· Configured HTTP cache: $HTTP_CACHE" From b0ce82e7e29fc9c7144e555bcad98f35592e6570 Mon Sep 17 00:00:00 2001 From: Maciej Kobus Date: Tue, 11 Jun 2024 15:31:19 +0200 Subject: [PATCH 08/32] Moved util functions to .utils script --- .ddev/commands/host/.utils | 9 +++++++++ .ddev/commands/host/ibexa-setup | 10 ++-------- 2 files changed, 11 insertions(+), 8 deletions(-) create mode 100755 .ddev/commands/host/.utils diff --git a/.ddev/commands/host/.utils b/.ddev/commands/host/.utils new file mode 100755 index 0000000..99a7b5c --- /dev/null +++ b/.ddev/commands/host/.utils @@ -0,0 +1,9 @@ +#!/bin/bash + +function verbose_output() { + if [ "$VERBOSE_INSTALL" = true ]; then + "$@" + else + "$@" > /dev/null + fi +} diff --git a/.ddev/commands/host/ibexa-setup b/.ddev/commands/host/ibexa-setup index bdb20b6..7b308b4 100755 --- a/.ddev/commands/host/ibexa-setup +++ b/.ddev/commands/host/ibexa-setup @@ -5,19 +5,13 @@ ## Usage: ibexa-setup ## Example: ddev ibexa-setup +source .ddev/commands/host/.utils + [ -z "$SETTINGS_FILE" ] && SETTINGS_FILE="./.ddev/.ibexa-instance-settings" [ -z "$PROVISION_FILE_GENERAL" ] && PROVISION_FILE_GENERAL="./.ddev/.ibexa-setup-general-provisioned" [ -z "$PROVISION_FILE_SERVICES" ] && PROVISION_FILE_SERVICES="./.ddev/.ibexa-setup-services-provisioned" [ -z "$VERBOSE_INSTALL" ] && VERBOSE_INSTALL=false -function verbose_output() { - if [ "$VERBOSE_INSTALL" = true ]; then - "$@" - else - "$@" > /dev/null - fi -} - if [ "$VERBOSE_INSTALL" != false ] && [ ! -f "$PROVISION_FILE_GENERAL" ] && [ ! -f "$PROVISION_FILE_SERVICES" ]; then clear fi From 1d0b68a06ffebbfad7ced40a3db216ecb135047d Mon Sep 17 00:00:00 2001 From: Maciej Kobus Date: Tue, 11 Jun 2024 15:31:43 +0200 Subject: [PATCH 09/32] Added ibexa-post-setup command --- .ddev/commands/host/ibexa-post-setup | 28 ++++++++++++++++++++++++++++ .ddev/config.yaml | 1 + 2 files changed, 29 insertions(+) create mode 100755 .ddev/commands/host/ibexa-post-setup diff --git a/.ddev/commands/host/ibexa-post-setup b/.ddev/commands/host/ibexa-post-setup new file mode 100755 index 0000000..44d2a80 --- /dev/null +++ b/.ddev/commands/host/ibexa-post-setup @@ -0,0 +1,28 @@ +#!/bin/bash + +## #ddev-generated +## Description: Provides additional setup routines after composer project is installed +## Usage: ibexa-post-setup +## Example: ddev ibexa-post-setup + +source .ddev/commands/host/.utils + +[ -z "$SETTINGS_FILE" ] && SETTINGS_FILE="./.ddev/.ibexa-instance-settings" +[ -z "$PROVISION_FILE_GENERAL" ] && PROVISION_FILE_GENERAL="./.ddev/.ibexa-setup-general-provisioned" +[ -z "$PROVISION_FILE_SERVICES" ] && PROVISION_FILE_SERVICES="./.ddev/.ibexa-setup-services-provisioned" +[ -z "$VERBOSE_INSTALL" ] && VERBOSE_INSTALL=false + +if [ "$VERBOSE_INSTALL" != false ]; then + clear +fi + +if [ ! -f "$SETTINGS_FILE" ] || [ ! -f "$PROVISION_FILE_GENERAL" ] || [ ! -f "$PROVISION_FILE_SERVICES" ]; then + echo "Setup not finished. Run this command after executing ibexa-setup." + exit 1 +fi + +source $SETTINGS_FILE + + + +ddev restart diff --git a/.ddev/config.yaml b/.ddev/config.yaml index fa97fd1..18e0ee8 100644 --- a/.ddev/config.yaml +++ b/.ddev/config.yaml @@ -17,3 +17,4 @@ hooks: - exec-host: "ddev ibexa-configurator" - exec-host: "ddev ibexa-setup" - exec-host: "ddev ibexa-installer" + - exec-host: "ddev ibexa-post-setup" From b1abd44df99172184caa69fef4f297716970a888 Mon Sep 17 00:00:00 2001 From: Maciej Kobus Date: Thu, 27 Jun 2024 14:54:07 +0200 Subject: [PATCH 10/32] Prompt for credentials when updates.ibexa.co cannot be accessed --- .ddev/commands/web/ibexa-installer | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.ddev/commands/web/ibexa-installer b/.ddev/commands/web/ibexa-installer index 1c16cc8..ad03554 100755 --- a/.ddev/commands/web/ibexa-installer +++ b/.ddev/commands/web/ibexa-installer @@ -39,8 +39,16 @@ echo "πŸš€ Installing `(bold "$PRODUCT_TYPE v$PRODUCT_VERSION")`" if [ "$DXP_EDITION" != "oss" ] || [ "$INSTALL_SAMPLE_DATA" = true ]; then echo "Adding updates.ibexa.co repository to composer.json" - echo "You might be prompted for repository credentials during installation" execute_with_spinner "Updating composer.json..." composer config repositories.ibexa composer https://updates.ibexa.co + + composer search --only-vendor ibexa > /dev/null 2>&1 + + if [[ "$?" != 0 ]]; then + echo "❗️Cannot access updates.ibexa.co" + echo "Please provide your composer auth details to ddev and re-run \"ddev start\". The process will continue using previously configured settings." + exit 1 + fi + fi composer config extra.runtime.error_handler "\\Ibexa\\Contracts\\Core\\MVC\\Symfony\\ErrorHandler\\Php82HideDeprecationsErrorHandler" From cb09b74218765f2fb6405449a27e43ce105e4ab6 Mon Sep 17 00:00:00 2001 From: Maciej Kobus Date: Thu, 27 Jun 2024 14:54:37 +0200 Subject: [PATCH 11/32] Install ibexa/test-fixtures in dev version --- .ddev/commands/web/ibexa-installer | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ddev/commands/web/ibexa-installer b/.ddev/commands/web/ibexa-installer index ad03554..5cd04ff 100755 --- a/.ddev/commands/web/ibexa-installer +++ b/.ddev/commands/web/ibexa-installer @@ -64,7 +64,7 @@ echo "βœ… Installed Flex recipe" # Install test fixtures if [ "$INSTALL_SAMPLE_DATA" = true ]; then - execute_with_spinner "Installing ibexa/test-fixtures package" composer require ibexa/test-fixtures:"$PRODUCT_VERSION" --no-scripts --no-interaction + execute_with_spinner "Installing ibexa/test-fixtures package" composer require ibexa/test-fixtures --no-scripts --no-interaction echo "βœ… Installed ibexa/test-fixtures package" fi From e4e3ec5e741d7635cfb0a40cdab7233db7292441 Mon Sep 17 00:00:00 2001 From: Maciej Kobus Date: Thu, 27 Jun 2024 14:55:00 +0200 Subject: [PATCH 12/32] Minor cleanups in ibexa-installer --- .ddev/commands/web/ibexa-installer | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/.ddev/commands/web/ibexa-installer b/.ddev/commands/web/ibexa-installer index 5cd04ff..a3cb47f 100755 --- a/.ddev/commands/web/ibexa-installer +++ b/.ddev/commands/web/ibexa-installer @@ -77,15 +77,6 @@ fi execute_with_spinner "Running Composer scripts..." composer run post-update-cmd echo "βœ… Scripts finished successfully" -#execute_with_spinner "Dropping database for fresh install" php bin/console doctrine:database:drop --force -#echo "βœ… Database dropped" -# -#execute_with_spinner "Removing existing migrations" rm -rf src/Migrations/Ibexa -#echo "βœ… Migrations removed" -# -#execute_with_spinner "Clearing cache" php bin/console c:c --env=prod -#echo "βœ… Cache cleared" - execute_with_spinner "Installing database..." php bin/console ibexa:install echo "βœ… Database installed" @@ -94,6 +85,7 @@ if [ "$SEARCH_ENGINE" = "solr" ] || [ "$SEARCH_ENGINE" = "elasticsearch" ]; then execute_with_spinner "Putting Elasticsearch index template" php bin/console ibexa:elasticsearch:put-index-template echo "βœ… Put Elasticsearch index template" fi + execute_with_spinner "Reindexing search data" php bin/console ibexa:reindex echo "βœ… Reindexed search data" fi @@ -124,7 +116,7 @@ gum style --border double --margin "1 1" --padding "1 1" --width 60 \ "" \ "Run `(bold "ddev describe")` for more details" -echo "πŸ“§ Run `(bold "ddev mailpit")` to launch Mailpit interface and see catched e-mails" +echo "πŸ“§ Run `(bold "ddev mailpit")` to launch Mailpit interface and see caught e-mails" echo "πŸ—„οΈ Run `(bold "ddev get ddev/ddev-phpmyadmin")` to install PHPMyAdmin" echo "πŸ—„οΈ Run `(bold "ddev querious|sequelace|tableplus|dbeaver")` to launch database client apps" echo "" From 1f62f8eea90a7df65d4657d3ea1a9b41dae5b93f Mon Sep 17 00:00:00 2001 From: Maciej Kobus Date: Thu, 27 Jun 2024 14:55:27 +0200 Subject: [PATCH 13/32] ibexa-configurator: Dump env variables to settings file in a nicer way --- .ddev/commands/web/ibexa-configurator | 38 +++++++++++++-------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/.ddev/commands/web/ibexa-configurator b/.ddev/commands/web/ibexa-configurator index 8f39d52..84c1d99 100755 --- a/.ddev/commands/web/ibexa-configurator +++ b/.ddev/commands/web/ibexa-configurator @@ -316,24 +316,24 @@ function select_configuration() { fi } -function save_changes() { - touch "$INSTANCE_SETTINGS_FILE" - - echo "DXP_EDITION=\"$DXP_EDITION\"" >> $INSTANCE_SETTINGS_FILE - echo "PRODUCT_TYPE=\"$PRODUCT_TYPE\"" >> $INSTANCE_SETTINGS_FILE - echo "PRODUCT_VERSION=\"$PRODUCT_VERSION\"" >> $INSTANCE_SETTINGS_FILE - echo "PHP_VERSION=\"$PHP_VERSION\"" >> $INSTANCE_SETTINGS_FILE - echo "NODE_VERSION=\"$NODE_VERSION\"" >> $INSTANCE_SETTINGS_FILE - echo "DATABASE=\"$DATABASE\"" >> $INSTANCE_SETTINGS_FILE - echo "DATABASE_VERSION=\"$DATABASE_VERSION\"" >> $INSTANCE_SETTINGS_FILE - echo "HTTP_CACHE=\"$HTTP_CACHE\"" >> $INSTANCE_SETTINGS_FILE - echo "APP_CACHE=\"$APP_CACHE\"" >> $INSTANCE_SETTINGS_FILE - echo "SEARCH_ENGINE=\"$SEARCH_ENGINE\"" >> $INSTANCE_SETTINGS_FILE - echo "INSTALL_SAMPLE_DATA=$INSTALL_SAMPLE_DATA" >> $INSTANCE_SETTINGS_FILE - echo "INSTALL_PROFILER=$INSTALL_PROFILER" >> $INSTANCE_SETTINGS_FILE - echo "APP_ENV=\"$APP_ENV\"" >> $INSTANCE_SETTINGS_FILE - echo "HTTP_SERVER=\"$HTTP_SERVER\"" >> $INSTANCE_SETTINGS_FILE - echo "INSTALL_CLOUD_CONFIG=$INSTALL_CLOUD_CONFIG" >> $INSTANCE_SETTINGS_FILE +function save_settings_file() { + { + declare -p DXP_EDITION + declare -p PRODUCT_TYPE + declare -p PRODUCT_VERSION + declare -p PHP_VERSION + declare -p NODE_VERSION + declare -p DATABASE + declare -p DATABASE_VERSION + declare -p HTTP_CACHE + declare -p APP_CACHE + declare -p SEARCH_ENGINE + declare -p INSTALL_SAMPLE_DATA + declare -p INSTALL_PROFILER + declare -p APP_ENV + declare -p HTTP_SERVER + declare -p INSTALL_CLOUD_CONFIG + } > "$INSTANCE_SETTINGS_FILE" } # @@ -359,7 +359,7 @@ then select_configuration fi -save_changes +save_settings_file From 386daec06c40e82201b964d224829ab3e79e52be Mon Sep 17 00:00:00 2001 From: Maciej Kobus Date: Thu, 27 Jun 2024 14:56:09 +0200 Subject: [PATCH 14/32] ibexa-post-setup: Prevent running post-setup on every restart --- .ddev/commands/host/ibexa-post-setup | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.ddev/commands/host/ibexa-post-setup b/.ddev/commands/host/ibexa-post-setup index 44d2a80..cba0e4a 100755 --- a/.ddev/commands/host/ibexa-post-setup +++ b/.ddev/commands/host/ibexa-post-setup @@ -11,6 +11,12 @@ source .ddev/commands/host/.utils [ -z "$PROVISION_FILE_GENERAL" ] && PROVISION_FILE_GENERAL="./.ddev/.ibexa-setup-general-provisioned" [ -z "$PROVISION_FILE_SERVICES" ] && PROVISION_FILE_SERVICES="./.ddev/.ibexa-setup-services-provisioned" [ -z "$VERBOSE_INSTALL" ] && VERBOSE_INSTALL=false +[ -z "$PROVISION_FILE_POST_SETUP" ] && PROVISION_FILE_POST_SETUP="./.ddev/.ibexa-setup-post-provisioned" + +if [ -f "$PROVISION_FILE_POST_SETUP" ]; then + # Nothing to do + exit 0 +fi if [ "$VERBOSE_INSTALL" != false ]; then clear @@ -23,6 +29,7 @@ fi source $SETTINGS_FILE +# todo - +touch "$PROVISION_FILE_POST_SETUP" ddev restart From dc653ea4bf84179619e9511c91e4c4a1ac18aeeb Mon Sep 17 00:00:00 2001 From: Maciej Kobus Date: Thu, 27 Jun 2024 15:52:32 +0200 Subject: [PATCH 15/32] ibexa-configurator: Improved displaying setup details --- .ddev/commands/web/ibexa-configurator | 51 ++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 5 deletions(-) diff --git a/.ddev/commands/web/ibexa-configurator b/.ddev/commands/web/ibexa-configurator index 84c1d99..c740511 100755 --- a/.ddev/commands/web/ibexa-configurator +++ b/.ddev/commands/web/ibexa-configurator @@ -29,8 +29,8 @@ IBEXA_DXP_PRODUCTS=("oss" "headless" "experience" "commerce") [ -z "$INSTALL_CLOUD_CONFIG" ] && INSTALL_CLOUD_CONFIG=true if [ -f "$INSTANCE_SETTINGS_FILE" ]; then - # Nothing to do - exit 0 + # Nothing to do + exit 0 fi function detect_version() { @@ -286,12 +286,53 @@ function configure_cloud() { esac } +function format_bool() { + if [ $1 ]; then + echo "yes" + else + echo "no" + fi +} + +function info_table() { + gum style \ + --border double \ + --align center --margin "0" --padding "1 2" \ + "$@" +} + function print_selected_settings() { echo "${1}" # print title - echo "$PHP_VERSION,$NODE_VERSION,$HTTP_SERVER,$HTTP_CACHE,$DATABASE ($DATABASE_VERSION),$APP_CACHE,$SEARCH_ENGINE,$LABEL_INSTALL_SAMPLE_DATA" \ - | gum table --print --columns "PHP,Node,Server,HTTP Cache,Database,Cache,Search engine,Sample data" - + TABLE_APPLICATION=$(info_table "`(bold Application)`" \ + "" \ + "`(faint "Product:")` `(bold "$PRODUCT_TYPE")`" \ + "`(faint "Version:")` `(bold "$PRODUCT_VERSION")`" \ + "") + + TABLE_SERVICES=$(info_table --border-foreground "#F4B19B" "`(bold Services)`" \ + "" \ + "`(faint "HTTP Cache:")` `(bold "$HTTP_CACHE")`" \ + "`(faint "App Cache:")` `(bold "$APP_CACHE")`" \ + "`(faint "Search Engine:")` `(bold "$SEARCH_ENGINE")`") + + TABLE_ENVIRONMENT=$(info_table --border-foreground "#FFE6D7" "`(bold Environment)`" \ + "" \ + "`(faint "Web Server:")` `(bold "$HTTP_SERVER")`" \ + "`(faint "PHP:")` `(bold "$PHP_VERSION")`" \ + "`(faint "Node:")` `(bold "$NODE_VERSION")`" \ + "`(faint "Database:")` `(bold "$DATABASE")` `(faint "("$DATABASE_VERSION")")`") + + TABLE_EXTRAS=$(info_table --border-foreground "#78B1E0" "`(bold Extras)`" \ + "" \ + "`(faint "Install sample data:")` `(bold $(format_bool "$INSTALL_SAMPLE_DATA"))`" \ + "`(faint "Install Ibexa Cloud config:")` `(bold $(format_bool "$INSTALL_CLOUD_CONFIG"))`" \ + "`(faint "Install Symfony Profiler:")` `(bold $(format_bool "$INSTALL_PROFILER"))`" \ + "`(faint "App environment:")` `(bold "$APP_ENV")`") + + ROW_1=$(gum join "$TABLE_APPLICATION" "$TABLE_SERVICES") + ROW_2=$(gum join "$TABLE_ENVIRONMENT" "$TABLE_EXTRAS") + gum join --align center --vertical "$ROW_1" "$ROW_2" echo "" } From 1521837101339ed7ba501a6b587ad46ff10c9278 Mon Sep 17 00:00:00 2001 From: Maciej Kobus Date: Thu, 27 Jun 2024 16:04:22 +0200 Subject: [PATCH 16/32] ibexa-installer: Check if ibexa/test-fixtures can be installed before attempting installation --- .ddev/commands/web/ibexa-installer | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/.ddev/commands/web/ibexa-installer b/.ddev/commands/web/ibexa-installer index a3cb47f..9ff23bf 100755 --- a/.ddev/commands/web/ibexa-installer +++ b/.ddev/commands/web/ibexa-installer @@ -37,7 +37,7 @@ banner "Interactive Installation Tool" echo "πŸš€ Installing `(bold "$PRODUCT_TYPE v$PRODUCT_VERSION")`" -if [ "$DXP_EDITION" != "oss" ] || [ "$INSTALL_SAMPLE_DATA" = true ]; then +if [ "$DXP_EDITION" != "oss" ]; then echo "Adding updates.ibexa.co repository to composer.json" execute_with_spinner "Updating composer.json..." composer config repositories.ibexa composer https://updates.ibexa.co @@ -64,8 +64,15 @@ echo "βœ… Installed Flex recipe" # Install test fixtures if [ "$INSTALL_SAMPLE_DATA" = true ]; then - execute_with_spinner "Installing ibexa/test-fixtures package" composer require ibexa/test-fixtures --no-scripts --no-interaction - echo "βœ… Installed ibexa/test-fixtures package" + composer show --available ibexa/test-fixtures > /dev/null 2>&1 + + if [[ "$?" == 0 ]]; then + execute_with_spinner "Installing ibexa/test-fixtures package" composer require ibexa/test-fixtures --no-scripts --no-interaction + echo "βœ… Installed ibexa/test-fixtures package" + else + echo "⚠️ `(bold "ibexa/test-fixtures")` package is unavailable. Cannot install sample data." + fi + fi # Install profiler From 68d1ec8668e6b5c28298cda03621c133565dab14 Mon Sep 17 00:00:00 2001 From: Maciej Kobus Date: Fri, 28 Jun 2024 09:46:46 +0200 Subject: [PATCH 17/32] ibexa-installer: Check updates.ibexa.co auth problems --- .ddev/commands/web/ibexa-installer | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.ddev/commands/web/ibexa-installer b/.ddev/commands/web/ibexa-installer index 9ff23bf..53f8faf 100755 --- a/.ddev/commands/web/ibexa-installer +++ b/.ddev/commands/web/ibexa-installer @@ -38,10 +38,8 @@ banner "Interactive Installation Tool" echo "πŸš€ Installing `(bold "$PRODUCT_TYPE v$PRODUCT_VERSION")`" if [ "$DXP_EDITION" != "oss" ]; then - echo "Adding updates.ibexa.co repository to composer.json" - execute_with_spinner "Updating composer.json..." composer config repositories.ibexa composer https://updates.ibexa.co - - composer search --only-vendor ibexa > /dev/null 2>&1 + execute_with_spinner "Adding updates.ibexa.co repository to composer.json..." composer config repositories.ibexa composer https://updates.ibexa.co + execute_with_spinner "Checking updates.ibexa.co availability" composer require "ibexa/$DXP_EDITION:$PRODUCT_VERSION" -W --no-scripts --no-plugins --no-install --no-interaction > /dev/null 2>&1 if [[ "$?" != 0 ]]; then echo "❗️Cannot access updates.ibexa.co" From 18c746ac067c244042d3444d0b0f08d60db54f1c Mon Sep 17 00:00:00 2001 From: Maciej Kobus Date: Fri, 28 Jun 2024 11:41:16 +0200 Subject: [PATCH 18/32] ibexa-installer: Check updates.ibexa.co auth problems --- .ddev/commands/web/ibexa-installer | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/.ddev/commands/web/ibexa-installer b/.ddev/commands/web/ibexa-installer index 53f8faf..0fcd080 100755 --- a/.ddev/commands/web/ibexa-installer +++ b/.ddev/commands/web/ibexa-installer @@ -26,6 +26,12 @@ ADMIN_PASSWORD=publish # Main # +function composer_auth_error() { + echo "❗️ Cannot access `(faint updates.ibexa.co)`" + echo "Please provide your composer auth details to ddev and re-run `(faint "ddev start")`. The process will continue using previously configured settings." + exit 1 +} + if [ "$VERBOSE_INSTALL" = false ]; then clear fi @@ -35,18 +41,13 @@ git config --global --add safe.directory /var/www/html banner "Interactive Installation Tool" -echo "πŸš€ Installing `(bold "$PRODUCT_TYPE v$PRODUCT_VERSION")`" +echo "πŸš€ Product to be installed: `(bold "$PRODUCT_TYPE v$PRODUCT_VERSION")`" if [ "$DXP_EDITION" != "oss" ]; then - execute_with_spinner "Adding updates.ibexa.co repository to composer.json..." composer config repositories.ibexa composer https://updates.ibexa.co - execute_with_spinner "Checking updates.ibexa.co availability" composer require "ibexa/$DXP_EDITION:$PRODUCT_VERSION" -W --no-scripts --no-plugins --no-install --no-interaction > /dev/null 2>&1 - - if [[ "$?" != 0 ]]; then - echo "❗️Cannot access updates.ibexa.co" - echo "Please provide your composer auth details to ddev and re-run \"ddev start\". The process will continue using previously configured settings." - exit 1 - fi - + trap 'composer_auth_error' ERR + composer config repositories.ibexa composer https://updates.ibexa.co --quiet > /dev/null 2>&1 + composer require "ibexa/$DXP_EDITION:$PRODUCT_VERSION" -W --no-scripts --no-plugins --no-install --no-interaction --quiet > /dev/null 2>&1 + trap 'error_handler' ERR fi composer config extra.runtime.error_handler "\\Ibexa\\Contracts\\Core\\MVC\\Symfony\\ErrorHandler\\Php82HideDeprecationsErrorHandler" @@ -82,7 +83,7 @@ fi execute_with_spinner "Running Composer scripts..." composer run post-update-cmd echo "βœ… Scripts finished successfully" -execute_with_spinner "Installing database..." php bin/console ibexa:install +execute_with_spinner "Installing database schema and data..." php bin/console ibexa:install echo "βœ… Database installed" if [ "$SEARCH_ENGINE" = "solr" ] || [ "$SEARCH_ENGINE" = "elasticsearch" ]; then From 485967150e13572b1ae27a16b062ca99893597cf Mon Sep 17 00:00:00 2001 From: Maciej Kobus Date: Fri, 28 Jun 2024 11:50:14 +0200 Subject: [PATCH 19/32] ibexa-post-setup: Removed post-setup step --- .ddev/commands/host/ibexa-post-setup | 35 ---------------------------- .ddev/config.yaml | 1 - 2 files changed, 36 deletions(-) delete mode 100755 .ddev/commands/host/ibexa-post-setup diff --git a/.ddev/commands/host/ibexa-post-setup b/.ddev/commands/host/ibexa-post-setup deleted file mode 100755 index cba0e4a..0000000 --- a/.ddev/commands/host/ibexa-post-setup +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/bash - -## #ddev-generated -## Description: Provides additional setup routines after composer project is installed -## Usage: ibexa-post-setup -## Example: ddev ibexa-post-setup - -source .ddev/commands/host/.utils - -[ -z "$SETTINGS_FILE" ] && SETTINGS_FILE="./.ddev/.ibexa-instance-settings" -[ -z "$PROVISION_FILE_GENERAL" ] && PROVISION_FILE_GENERAL="./.ddev/.ibexa-setup-general-provisioned" -[ -z "$PROVISION_FILE_SERVICES" ] && PROVISION_FILE_SERVICES="./.ddev/.ibexa-setup-services-provisioned" -[ -z "$VERBOSE_INSTALL" ] && VERBOSE_INSTALL=false -[ -z "$PROVISION_FILE_POST_SETUP" ] && PROVISION_FILE_POST_SETUP="./.ddev/.ibexa-setup-post-provisioned" - -if [ -f "$PROVISION_FILE_POST_SETUP" ]; then - # Nothing to do - exit 0 -fi - -if [ "$VERBOSE_INSTALL" != false ]; then - clear -fi - -if [ ! -f "$SETTINGS_FILE" ] || [ ! -f "$PROVISION_FILE_GENERAL" ] || [ ! -f "$PROVISION_FILE_SERVICES" ]; then - echo "Setup not finished. Run this command after executing ibexa-setup." - exit 1 -fi - -source $SETTINGS_FILE - -# todo - -touch "$PROVISION_FILE_POST_SETUP" -ddev restart diff --git a/.ddev/config.yaml b/.ddev/config.yaml index 18e0ee8..fa97fd1 100644 --- a/.ddev/config.yaml +++ b/.ddev/config.yaml @@ -17,4 +17,3 @@ hooks: - exec-host: "ddev ibexa-configurator" - exec-host: "ddev ibexa-setup" - exec-host: "ddev ibexa-installer" - - exec-host: "ddev ibexa-post-setup" From 01a274ffb0fe327e1029c2a065db3fbe8b674443 Mon Sep 17 00:00:00 2001 From: Maciej Kobus Date: Fri, 28 Jun 2024 11:53:42 +0200 Subject: [PATCH 20/32] ibexa-installer: Minor text corrections --- .ddev/commands/web/ibexa-installer | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ddev/commands/web/ibexa-installer b/.ddev/commands/web/ibexa-installer index 0fcd080..78ebdce 100755 --- a/.ddev/commands/web/ibexa-installer +++ b/.ddev/commands/web/ibexa-installer @@ -124,7 +124,7 @@ gum style --border double --margin "1 1" --padding "1 1" --width 60 \ echo "πŸ“§ Run `(bold "ddev mailpit")` to launch Mailpit interface and see caught e-mails" echo "πŸ—„οΈ Run `(bold "ddev get ddev/ddev-phpmyadmin")` to install PHPMyAdmin" -echo "πŸ—„οΈ Run `(bold "ddev querious|sequelace|tableplus|dbeaver")` to launch database client apps" +echo "πŸ—„οΈ Run `(bold "ddev querious|sequelace|tableplus|dbeaver")` to launch database client app" echo "" echo "πŸ“¦οΈ Run `(bold "ddev composer ...")` to execute Composer commands" echo "🐘️ Run `(bold "ddev php ...")` to execute PHP scripts" From 30c8dfa072f12719347434ce5bea6892013d76e8 Mon Sep 17 00:00:00 2001 From: Maciej Kobus Date: Fri, 28 Jun 2024 12:10:53 +0200 Subject: [PATCH 21/32] ibexa-installer: Added spinner during auth check --- .ddev/commands/web/ibexa-installer | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ddev/commands/web/ibexa-installer b/.ddev/commands/web/ibexa-installer index 78ebdce..65d5966 100755 --- a/.ddev/commands/web/ibexa-installer +++ b/.ddev/commands/web/ibexa-installer @@ -46,7 +46,7 @@ echo "πŸš€ Product to be installed: `(bold "$PRODUCT_TYPE v$PRODUCT_VERSION")`" if [ "$DXP_EDITION" != "oss" ]; then trap 'composer_auth_error' ERR composer config repositories.ibexa composer https://updates.ibexa.co --quiet > /dev/null 2>&1 - composer require "ibexa/$DXP_EDITION:$PRODUCT_VERSION" -W --no-scripts --no-plugins --no-install --no-interaction --quiet > /dev/null 2>&1 + execute_with_spinner "Checking `(faint updates.ibexa.co)` authorization" composer require "ibexa/$DXP_EDITION:$PRODUCT_VERSION" -W --no-scripts --no-plugins --no-install --no-interaction --quiet trap 'error_handler' ERR fi From a7a506008951f09cd19aa5d2b0209714275fdd22 Mon Sep 17 00:00:00 2001 From: Maciej Kobus Date: Fri, 28 Jun 2024 12:21:14 +0200 Subject: [PATCH 22/32] ibexa-installer: Added status message on successful auth --- .ddev/commands/web/ibexa-installer | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.ddev/commands/web/ibexa-installer b/.ddev/commands/web/ibexa-installer index 65d5966..ce7bd39 100755 --- a/.ddev/commands/web/ibexa-installer +++ b/.ddev/commands/web/ibexa-installer @@ -48,6 +48,8 @@ if [ "$DXP_EDITION" != "oss" ]; then composer config repositories.ibexa composer https://updates.ibexa.co --quiet > /dev/null 2>&1 execute_with_spinner "Checking `(faint updates.ibexa.co)` authorization" composer require "ibexa/$DXP_EDITION:$PRODUCT_VERSION" -W --no-scripts --no-plugins --no-install --no-interaction --quiet trap 'error_handler' ERR + + echo "βœ… `(faint updates.ibexa.co)` is authorized" fi composer config extra.runtime.error_handler "\\Ibexa\\Contracts\\Core\\MVC\\Symfony\\ErrorHandler\\Php82HideDeprecationsErrorHandler" From 15b53f19c2bf03eca6a50834648d401f7a1183d9 Mon Sep 17 00:00:00 2001 From: Maciej Kobus Date: Fri, 28 Jun 2024 12:33:29 +0200 Subject: [PATCH 23/32] ibexa-installer: Improved text readability --- .ddev/commands/web/ibexa-installer | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.ddev/commands/web/ibexa-installer b/.ddev/commands/web/ibexa-installer index ce7bd39..4aed5ed 100755 --- a/.ddev/commands/web/ibexa-installer +++ b/.ddev/commands/web/ibexa-installer @@ -46,16 +46,16 @@ echo "πŸš€ Product to be installed: `(bold "$PRODUCT_TYPE v$PRODUCT_VERSION")`" if [ "$DXP_EDITION" != "oss" ]; then trap 'composer_auth_error' ERR composer config repositories.ibexa composer https://updates.ibexa.co --quiet > /dev/null 2>&1 - execute_with_spinner "Checking `(faint updates.ibexa.co)` authorization" composer require "ibexa/$DXP_EDITION:$PRODUCT_VERSION" -W --no-scripts --no-plugins --no-install --no-interaction --quiet + execute_with_spinner "Checking `(bold updates.ibexa.co)` authorization" composer require "ibexa/$DXP_EDITION:$PRODUCT_VERSION" -W --no-scripts --no-plugins --no-install --no-interaction --quiet trap 'error_handler' ERR - echo "βœ… `(faint updates.ibexa.co)` is authorized" + echo "βœ… Repository `(bold updates.ibexa.co)` is reachable" fi composer config extra.runtime.error_handler "\\Ibexa\\Contracts\\Core\\MVC\\Symfony\\ErrorHandler\\Php82HideDeprecationsErrorHandler" -execute_with_spinner "Installing ibexa/${DXP_EDITION} package..." composer require "ibexa/$DXP_EDITION:$PRODUCT_VERSION" -W --no-scripts --no-interaction -echo "βœ… Package ibexa/${DXP_EDITION} installed successfully" +execute_with_spinner "Installing `(bold ibexa/${DXP_EDITION})` package..." composer require "ibexa/$DXP_EDITION:$PRODUCT_VERSION" -W --no-scripts --no-interaction +echo "βœ… Package `(bold ibexa/${DXP_EDITION})` installed successfully" execute_with_spinner "Initializing git repository..." git init > /dev/null && git add . > /dev/null && git commit -m "Installed Ibexa DXP" > /dev/null echo "βœ… Initialized git repository" From dcae97cf9c1fcfc5741fefc08788c32bccc1b22b Mon Sep 17 00:00:00 2001 From: Maciej Kobus Date: Fri, 12 Jul 2024 10:18:34 +0200 Subject: [PATCH 24/32] ibexa-configurator: Introduce flag to distinguish installations from product skeleton --- .ddev/commands/web/ibexa-configurator | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.ddev/commands/web/ibexa-configurator b/.ddev/commands/web/ibexa-configurator index c740511..771a60d 100755 --- a/.ddev/commands/web/ibexa-configurator +++ b/.ddev/commands/web/ibexa-configurator @@ -37,9 +37,11 @@ function detect_version() { if [ "$DXP_EDITION" != "website" ] && [ -f composer.lock ]; then MIN_STABILITY="`(jq -r '."minimum-stability"' composer.lock)`" PRODUCT_VERSION="`(jq -r '.packages[] | select(.name == "ibexa/oss") | .version' composer.lock | sed 's/^v//')`" + INSTALL_FROM_EDITION_SKELETON=true else MIN_STABILITY="`(jq -r '."minimum-stability"' composer.json)`" PRODUCT_VERSION="`(jq -r '.extra."branch-alias"."dev-main"' composer.json)`" + INSTALL_FROM_EDITION_SKELETON=false fi } @@ -374,6 +376,7 @@ function save_settings_file() { declare -p APP_ENV declare -p HTTP_SERVER declare -p INSTALL_CLOUD_CONFIG + declare -p INSTALL_FROM_EDITION_SKELETON } > "$INSTANCE_SETTINGS_FILE" } From b061aa212ab6a5537be30b26126039b47ed995c4 Mon Sep 17 00:00:00 2001 From: Maciej Kobus Date: Fri, 12 Jul 2024 10:18:52 +0200 Subject: [PATCH 25/32] ibexa-installer: Use different installation workflow for product skeletons --- .ddev/commands/web/ibexa-installer | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/.ddev/commands/web/ibexa-installer b/.ddev/commands/web/ibexa-installer index 4aed5ed..398d105 100755 --- a/.ddev/commands/web/ibexa-installer +++ b/.ddev/commands/web/ibexa-installer @@ -43,25 +43,37 @@ banner "Interactive Installation Tool" echo "πŸš€ Product to be installed: `(bold "$PRODUCT_TYPE v$PRODUCT_VERSION")`" +# Configure updates.ibexa.co composer repository, check availability (composer auth file could not be linked to ddev) if [ "$DXP_EDITION" != "oss" ]; then trap 'composer_auth_error' ERR - composer config repositories.ibexa composer https://updates.ibexa.co --quiet > /dev/null 2>&1 + if [ "$INSTALL_FROM_EDITION_SKELETON" == false ]; then + composer config repositories.ibexa composer https://updates.ibexa.co --quiet > /dev/null 2>&1 + fi execute_with_spinner "Checking `(bold updates.ibexa.co)` authorization" composer require "ibexa/$DXP_EDITION:$PRODUCT_VERSION" -W --no-scripts --no-plugins --no-install --no-interaction --quiet trap 'error_handler' ERR echo "βœ… Repository `(bold updates.ibexa.co)` is reachable" fi -composer config extra.runtime.error_handler "\\Ibexa\\Contracts\\Core\\MVC\\Symfony\\ErrorHandler\\Php82HideDeprecationsErrorHandler" +# PHP 8.x requires custom error handler to suppress deprecation warnings, it's already added to edition skeletons +if [ "$INSTALL_FROM_EDITION_SKELETON" == false ]; then + composer config extra.runtime.error_handler "\\Ibexa\\Contracts\\Core\\MVC\\Symfony\\ErrorHandler\\Php82HideDeprecationsErrorHandler" +fi -execute_with_spinner "Installing `(bold ibexa/${DXP_EDITION})` package..." composer require "ibexa/$DXP_EDITION:$PRODUCT_VERSION" -W --no-scripts --no-interaction -echo "βœ… Package `(bold ibexa/${DXP_EDITION})` installed successfully" +# Installation steps between website-skeleton and edition skeletons are different +if [ "$INSTALL_FROM_EDITION_SKELETON" == true ]; then + execute_with_spinner "Installing composer dependencies..." composer install -W --no-scripts --no-interaction + echo "βœ… Composer dependencies installed successfully" +else + execute_with_spinner "Installing `(bold ibexa/${DXP_EDITION})` package..." composer require "ibexa/$DXP_EDITION:$PRODUCT_VERSION" -W --no-scripts --no-interaction + echo "βœ… Package `(bold ibexa/${DXP_EDITION})` installed successfully" -execute_with_spinner "Initializing git repository..." git init > /dev/null && git add . > /dev/null && git commit -m "Installed Ibexa DXP" > /dev/null -echo "βœ… Initialized git repository" + execute_with_spinner "Initializing git repository..." git init > /dev/null && git add . > /dev/null && git commit -m "Installed Ibexa DXP" > /dev/null + echo "βœ… Initialized git repository" -execute_with_spinner "Installing Flex recipe..." composer recipes:install ibexa/${DXP_EDITION} --force --reset -echo "βœ… Installed Flex recipe" + execute_with_spinner "Installing Flex recipe..." composer recipes:install ibexa/${DXP_EDITION} --force --reset + echo "βœ… Installed Flex recipe" +fi # Install test fixtures if [ "$INSTALL_SAMPLE_DATA" = true ]; then From f2d8c74b28415d2fa9a144a7436c5d2ea1e70e1d Mon Sep 17 00:00:00 2001 From: Maciej Kobus Date: Fri, 12 Jul 2024 13:03:23 +0200 Subject: [PATCH 26/32] ibexa-installer: Fix for installing from composer.lock --- .ddev/commands/web/ibexa-installer | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ddev/commands/web/ibexa-installer b/.ddev/commands/web/ibexa-installer index 398d105..c837bc4 100755 --- a/.ddev/commands/web/ibexa-installer +++ b/.ddev/commands/web/ibexa-installer @@ -62,7 +62,7 @@ fi # Installation steps between website-skeleton and edition skeletons are different if [ "$INSTALL_FROM_EDITION_SKELETON" == true ]; then - execute_with_spinner "Installing composer dependencies..." composer install -W --no-scripts --no-interaction + execute_with_spinner "Installing composer dependencies..." composer install --no-scripts --no-interaction echo "βœ… Composer dependencies installed successfully" else execute_with_spinner "Installing `(bold ibexa/${DXP_EDITION})` package..." composer require "ibexa/$DXP_EDITION:$PRODUCT_VERSION" -W --no-scripts --no-interaction From 652c23509a4aefe68a9ba7a44bde07c7f6008de1 Mon Sep 17 00:00:00 2001 From: Maciej Kobus Date: Fri, 12 Jul 2024 13:05:52 +0200 Subject: [PATCH 27/32] ibexa-installer: Streamlined code style --- .ddev/commands/web/ibexa-installer | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.ddev/commands/web/ibexa-installer b/.ddev/commands/web/ibexa-installer index c837bc4..b35b9ef 100755 --- a/.ddev/commands/web/ibexa-installer +++ b/.ddev/commands/web/ibexa-installer @@ -32,7 +32,7 @@ function composer_auth_error() { exit 1 } -if [ "$VERBOSE_INSTALL" = false ]; then +if [ "$VERBOSE_INSTALL" == false ]; then clear fi @@ -76,10 +76,10 @@ else fi # Install test fixtures -if [ "$INSTALL_SAMPLE_DATA" = true ]; then +if [ "$INSTALL_SAMPLE_DATA" == true ]; then composer show --available ibexa/test-fixtures > /dev/null 2>&1 - if [[ "$?" == 0 ]]; then + if [ "$?" == 0 ]; then execute_with_spinner "Installing ibexa/test-fixtures package" composer require ibexa/test-fixtures --no-scripts --no-interaction echo "βœ… Installed ibexa/test-fixtures package" else @@ -89,7 +89,7 @@ if [ "$INSTALL_SAMPLE_DATA" = true ]; then fi # Install profiler -if [ "$INSTALL_PROFILER" = true ]; then +if [ "$INSTALL_PROFILER" == true ]; then execute_with_spinner "Installing Symfony Profiler" composer require symfony/profiler-pack --no-scripts --no-interaction echo "βœ… Installed Symfony Profiler" fi @@ -100,7 +100,7 @@ echo "βœ… Scripts finished successfully" execute_with_spinner "Installing database schema and data..." php bin/console ibexa:install echo "βœ… Database installed" -if [ "$SEARCH_ENGINE" = "solr" ] || [ "$SEARCH_ENGINE" = "elasticsearch" ]; then +if [ "$SEARCH_ENGINE" == "solr" ] || [ "$SEARCH_ENGINE" == "elasticsearch" ]; then if [ "$SEARCH_ENGINE" = "elasticsearch" ]; then execute_with_spinner "Putting Elasticsearch index template" php bin/console ibexa:elasticsearch:put-index-template echo "βœ… Put Elasticsearch index template" @@ -111,7 +111,7 @@ if [ "$SEARCH_ENGINE" = "solr" ] || [ "$SEARCH_ENGINE" = "elasticsearch" ]; then fi # Setup sample data -if [ "$INSTALL_SAMPLE_DATA" = true ]; then +if [ "$INSTALL_SAMPLE_DATA" == true ]; then execute_with_spinner "Installing sample data" php bin/console ibexa:test-fixtures:setup echo "βœ… Installed sample data" fi @@ -120,7 +120,7 @@ execute_with_spinner "Generating GraphQL schema" php bin/console ibexa:graphql:g echo "βœ… GraphQL schema generated" # Setup Ibexa Cloud -if [ "$INSTALL_CLOUD_CONFIG" = true ]; then +if [ "$INSTALL_CLOUD_CONFIG" == true ]; then execute_with_spinner "Installing Ibexa Cloud configuration" composer ibexa:setup --platformsh echo "βœ… Installed Ibexa Cloud configuration" fi From 68f1abb63072b45abed8b0cf1b42158467660620 Mon Sep 17 00:00:00 2001 From: Maciej Kobus Date: Fri, 12 Jul 2024 13:06:48 +0200 Subject: [PATCH 28/32] ibexa-setup: Streamlined code style --- .ddev/commands/host/ibexa-setup | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.ddev/commands/host/ibexa-setup b/.ddev/commands/host/ibexa-setup index 7b308b4..e858a62 100755 --- a/.ddev/commands/host/ibexa-setup +++ b/.ddev/commands/host/ibexa-setup @@ -78,11 +78,11 @@ DB_VERSION=$DATABASE_VERSION DB_CHARSET=utf8mb4 DB_COLLATION=utf8mb4_unicode_520_ci -if [ "$DATABASE" = "mariadb" ]; then +if [ "$DATABASE" == "mariadb" ]; then DB_VERSION=mariadb-`ddev exec -s db mysql -V | awk '{print $5}' | sed 's/-.*//'` fi -if [ "$DATABASE" = "postgres" ]; then +if [ "$DATABASE" == "postgres" ]; then DB_PORT=5432 DB_SCHEME=postgresql DB_CHARSET=utf8 @@ -98,7 +98,7 @@ echo "DATABASE_COLLATION=${DB_COLLATION}" >> .env.local echo "πŸ‘· Saved database details in .env.local" -if [ "$HTTP_CACHE" = "varnish" ]; then +if [ "$HTTP_CACHE" == "varnish" ]; then echo "# " >> .env.local echo "# dxp-installer generated" >> .env.local echo "TRUSTED_PROXIES=REMOTE_ADDR" >> .env.local @@ -111,7 +111,7 @@ fi echo "πŸ‘· Configured HTTP cache: $HTTP_CACHE" # Memcached -if [ "$APP_CACHE" = "memcached" ]; then +if [ "$APP_CACHE" == "memcached" ]; then echo "# " >> .env.local echo "# dxp-installer generated" >> .env.local echo "CACHE_POOL=\"cache.memcached\"" >> .env.local @@ -121,7 +121,7 @@ if [ "$APP_CACHE" = "memcached" ]; then fi # Redis -if [ "$APP_CACHE" = "redis" ]; then +if [ "$APP_CACHE" == "redis" ]; then echo "# " >> .env.local echo "# dxp-installer generated" >> .env.local echo "CACHE_POOL=cache.redis" >> .env.local @@ -137,7 +137,7 @@ fi echo "πŸ‘· Configured app cache: $APP_CACHE" # Solr -if [ "$SEARCH_ENGINE" = "solr" ]; then +if [ "$SEARCH_ENGINE" == "solr" ]; then echo "# " >> .env.local echo "# dxp-installer generated" >> .env.local echo "SEARCH_ENGINE=solr" >> .env.local @@ -148,7 +148,7 @@ if [ "$SEARCH_ENGINE" = "solr" ]; then fi # Elasticsearch -if [ "$SEARCH_ENGINE" = "elasticsearch" ]; then +if [ "$SEARCH_ENGINE" == "elasticsearch" ]; then echo "# " >> .env.local echo "# dxp-installer generated" >> .env.local echo "SEARCH_ENGINE=elasticsearch" >> .env.local From 0e54432d23898284ea3f0a9032fdc180747e0157 Mon Sep 17 00:00:00 2001 From: Maciej Kobus Date: Fri, 12 Jul 2024 13:10:51 +0200 Subject: [PATCH 29/32] ibexa-configurator: Fix for displaying yes/no values --- .ddev/commands/web/ibexa-configurator | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ddev/commands/web/ibexa-configurator b/.ddev/commands/web/ibexa-configurator index 771a60d..95f0e56 100755 --- a/.ddev/commands/web/ibexa-configurator +++ b/.ddev/commands/web/ibexa-configurator @@ -289,7 +289,7 @@ function configure_cloud() { } function format_bool() { - if [ $1 ]; then + if [ "$1" == true ]; then echo "yes" else echo "no" From e21a2ea27115d343eb530f25bb97f12c55eeca77 Mon Sep 17 00:00:00 2001 From: Maciej Kobus Date: Fri, 12 Jul 2024 13:11:04 +0200 Subject: [PATCH 30/32] ibexa-configurator: Reorder setup questions --- .ddev/commands/web/ibexa-configurator | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ddev/commands/web/ibexa-configurator b/.ddev/commands/web/ibexa-configurator index 95f0e56..8407587 100755 --- a/.ddev/commands/web/ibexa-configurator +++ b/.ddev/commands/web/ibexa-configurator @@ -342,8 +342,8 @@ function select_configuration() { configure_php configure_node configure_http_server - configure_http_cache configure_database + configure_http_cache configure_app_cache configure_search_engine configure_sample_data From d00cf2744d423256860998cbf844c693ea604264 Mon Sep 17 00:00:00 2001 From: Maciej Kobus Date: Fri, 12 Jul 2024 13:16:35 +0200 Subject: [PATCH 31/32] ibexa-installer: Use composer update when using PHP 8.1 --- .ddev/commands/web/ibexa-installer | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.ddev/commands/web/ibexa-installer b/.ddev/commands/web/ibexa-installer index b35b9ef..b3dd83d 100755 --- a/.ddev/commands/web/ibexa-installer +++ b/.ddev/commands/web/ibexa-installer @@ -62,8 +62,13 @@ fi # Installation steps between website-skeleton and edition skeletons are different if [ "$INSTALL_FROM_EDITION_SKELETON" == true ]; then - execute_with_spinner "Installing composer dependencies..." composer install --no-scripts --no-interaction + if [ "$PHP_VERSION" == "8.1" ]; then + execute_with_spinner "Installing composer dependencies..." composer update -W --no-scripts --no-interaction + else + execute_with_spinner "Installing composer dependencies..." composer install --no-scripts --no-interaction + fi echo "βœ… Composer dependencies installed successfully" + else execute_with_spinner "Installing `(bold ibexa/${DXP_EDITION})` package..." composer require "ibexa/$DXP_EDITION:$PRODUCT_VERSION" -W --no-scripts --no-interaction echo "βœ… Package `(bold ibexa/${DXP_EDITION})` installed successfully" From 46cb18d192558dc65e0487d092200801d4f1337d Mon Sep 17 00:00:00 2001 From: Maciej Kobus Date: Fri, 12 Jul 2024 13:26:17 +0200 Subject: [PATCH 32/32] ibexa-installer: Code style --- .ddev/commands/web/ibexa-installer | 1 - 1 file changed, 1 deletion(-) diff --git a/.ddev/commands/web/ibexa-installer b/.ddev/commands/web/ibexa-installer index b3dd83d..e25c5a4 100755 --- a/.ddev/commands/web/ibexa-installer +++ b/.ddev/commands/web/ibexa-installer @@ -68,7 +68,6 @@ if [ "$INSTALL_FROM_EDITION_SKELETON" == true ]; then execute_with_spinner "Installing composer dependencies..." composer install --no-scripts --no-interaction fi echo "βœ… Composer dependencies installed successfully" - else execute_with_spinner "Installing `(bold ibexa/${DXP_EDITION})` package..." composer require "ibexa/$DXP_EDITION:$PRODUCT_VERSION" -W --no-scripts --no-interaction echo "βœ… Package `(bold ibexa/${DXP_EDITION})` installed successfully"