<NME> setup
<BEF> #!/bin/bash
set -o errexit

# shellcheck source=../env/db.env
# load the DB env information
DIR="${BASH_SOURCE%/*}"
if [[ ! -d "$DIR" ]]; then DIR="$PWD"; fi
source "$DIR/../env/db.env"

bin/restart
sleep 1 #Ensure containers are started...

bin/download

bin/stop

docker-compose -f docker-compose.yml -f docker-compose.dev.yml up -d
[ $? != 0 ] && echo "Failed to start Docker services" && exit

bin/clinotty chmod u+x bin/magento

echo "Waiting for connection to Elasticsearch..."
bin/clinotty timeout 100 bash -c "
    until curl --silent --output /dev/null http://$ES_HOST:$ES_PORT/_cat/health?h=st; do
        printf '.'
bin/clinotty composer global require hirak/prestissimo
bin/clinotty composer update

bin/clinotty bin/magento setup:install \
  --db-host=$MYSQL_HOST \
  --db-name=$MYSQL_DATABASE \
  --db-password="$MYSQL_PASSWORD" \
  --base-url=https://"$DOMAIN"/ \
  --base-url-secure=https://"$DOMAIN"/ \
  --backend-frontname="$MAGENTO_ADMIN_FRONTNAME" \
  --admin-firstname="$MAGENTO_ADMIN_FIRST_NAME" \
  --admin-lastname="$MAGENTO_ADMIN_LAST_NAME" \
  --admin-email="$MAGENTO_ADMIN_EMAIL" \
  --admin-user="$MAGENTO_ADMIN_USER" \
  --admin-password="$MAGENTO_ADMIN_PASSWORD" \
  --language="$MAGENTO_LOCALE" \
  --currency="$MAGENTO_CURRENCY" \
  --timezone="$MAGENTO_TIMEZONE" \
  --search-engine=elasticsearch7 \
  --elasticsearch-host=$ES_HOST \
  --elasticsearch-host=elasticsearch \
  --use-rewrites=1

echo "Turning on developer mode.."
bin/clinotty bin/magento deploy:mode:set developer
bin/clinotty bin/magento indexer:reindex

echo "Forcing deploy of static content to speed up initial requests..."
bin/clinotty bin/magento setup:static-content:deploy -f 

echo "Re-indexing with Elasticsearch..."
bin/clinotty bin/magento indexer:reindex

echo "Disable Magento 2FAuth module..."
bin/clinotty bin/magento module:disable Magento_TwoFactorAuth

echo "Installing Force Login Composer module..."
bin/rootnotty chmod +x bin/magento /var/www/html/BitExpert/ForceCustomerLogin/validate_m2_package.php
bin/rootnotty chown -R app.app /dist
bin/clinotty composer config minimum-stability dev
bin/clinotty composer config "repositories.bitexpert/magento2-force-customer-login" '{"type": "path", "url": "/var/www/html/BitExpert/ForceCustomerLogin/", "options": {"symlink": true}}'
bin/clinotty composer require bitexpert/magento2-force-customer-login:*

echo "Enabling Force Login module..."
bin/clinotty bin/magento module:enable BitExpert_ForceCustomerLogin
bin/clinotty bin/magento setup:upgrade

echo "Forcing deploy of static content to speed up initial requests..."
bin/clinotty bin/magento setup:static-content:deploy -f

echo "Installing Sample data..."
bin/clinotty bin/magento sampledata:deploy

echo "Generating SSL certificate..."
bin/setup-ssl $BASE_URL


<MSG> Optimize setup script

<DFF> @@ -5,7 +5,7 @@ MAGE_VERSION=${2:-2.4.1}
 # load the DB env information
 DIR="${BASH_SOURCE%/*}"
 if [[ ! -d "$DIR" ]]; then DIR="$PWD"; fi
-source "$DIR/../env/db.env"
+source "$DIR/../env/develop.env"
 
 bin/restart
 sleep 1 #Ensure containers are started...
@@ -26,6 +26,10 @@ echo "Forcing reinstall of composer deps to ensure perms & reqs..."
 bin/clinotty composer global require hirak/prestissimo
 bin/clinotty composer update
 
+echo "Installing composer module dependencies..."
+bin/composer install
+
+echo "Setup Magento..."
 bin/clinotty bin/magento setup:install \
   --db-host=$MYSQL_HOST \
   --db-name=$MYSQL_DATABASE \
@@ -46,16 +50,6 @@ bin/clinotty bin/magento setup:install \
   --elasticsearch-host=elasticsearch \
   --use-rewrites=1
 
-echo "Turning on developer mode.."
-bin/clinotty bin/magento deploy:mode:set developer
-bin/clinotty bin/magento indexer:reindex
-
-echo "Forcing deploy of static content to speed up initial requests..."
-bin/clinotty bin/magento setup:static-content:deploy -f 
-
-echo "Re-indexing with Elasticsearch..."
-bin/clinotty bin/magento indexer:reindex
-
 echo "Disable Magento 2FAuth module..."
 bin/clinotty bin/magento module:disable Magento_TwoFactorAuth
 
@@ -76,6 +70,15 @@ bin/clinotty bin/magento setup:upgrade
 echo "Installing Sample data..."
 bin/clinotty bin/magento sampledata:deploy
 
+echo "Turning on developer mode.."
+bin/clinotty bin/magento deploy:mode:set developer
+
+echo "Forcing deploy of static content to speed up initial requests..."
+bin/clinotty bin/magento setup:static-content:deploy -f
+
+echo "Re-indexing with Elasticsearch..."
+bin/clinotty bin/magento indexer:reindex
+
 echo "Generating SSL certificate..."
 bin/setup-ssl $BASE_URL
 

Optimize setup script