123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- #!/bin/bash
- set -o errexit
- MEM_BYTES=$(docker info -f '{{.MemTotal}}')
- MEM_MB=$(( MEM_BYTES / 1000000 ))
- (( MEM_MB >= 6000 )) || {
- echo 'There must be at least 6GB of RAM allocated to Docker to continue.' >&2
- exit 1
- }
- # shellcheck source=../env/db.env
- source env/db.env
- # shellcheck source=../env/elasticsearch.env
- source env/elasticsearch.env
- # shellcheck source=../env/opensearch.env
- source env/opensearch.env
- # shellcheck source=../env/magento.env
- source env/magento.env
- # shellcheck source=../env/rabbitmq.env
- source env/rabbitmq.env
- DOMAIN=${1:-magento.test}
- bin/stop
- bin/start --no-dev
- [ $? != 0 ] && echo "Failed to start Docker services" && exit
- bin/clinotty chmod u+x bin/magento
- rm -rf src && mkdir src
- echo "Adding Magento modules to Composer allow-plugins directive..."
- bin/clinotty composer config --no-plugins allow-plugins.magento/magento-composer-installer true
- bin/clinotty composer config --no-plugins allow-plugins.magento/inventory-composer-installer true
- bin/clinotty composer config --no-plugins allow-plugins.laminas/laminas-dependency-plugin true
- bin/clinotty bin/magento setup:install \
- --db-host="$MYSQL_HOST" \
- --db-name="$MYSQL_DATABASE" \
- --db-user="$MYSQL_USER" \
- --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" \
- --amqp-host="$RABBITMQ_HOST" \
- --amqp-port="$RABBITMQ_PORT" \
- --amqp-user="$RABBITMQ_DEFAULT_USER" \
- --amqp-password="$RABBITMQ_DEFAULT_PASS" \
- --amqp-virtualhost="$RABBITMQ_DEFAULT_VHOST" \
- --cache-backend=redis \
- --cache-backend-redis-server=redis \
- --cache-backend-redis-db=0 \
- --page-cache=redis \
- --page-cache-redis-server=redis \
- --page-cache-redis-db=1 \
- --session-save=redis \
- --session-save-redis-host=redis \
- --session-save-redis-log-level=4 \
- --session-save-redis-db=2 \
- --elasticsearch-host=$OPENSEARCH_HOST \
- --elasticsearch-port=$OPENSEARCH_PORT \
- --use-rewrites=1 \
- --no-interaction
- echo "Copying files from container to host after install..."
- bin/copyfromcontainer --all
- 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 "Setting basic URL and generating SSL certificate..."
- bin/setup-domain "${DOMAIN}"
- echo "Fixing owner and permissions..."
- bin/fixowns
- bin/fixperms
- echo "Clearing the cache to apply updates..."
- bin/clinotty bin/magento cache:flush
- echo "Installing cron, run 'bin/cron start' to enable..."
- bin/clinotty bin/magento cron:install
- echo "Turning on developer mode..."
- bin/clinotty bin/magento deploy:mode:set developer
- cp -r .vscode src/
- echo "Docker development environment setup complete."
- echo "You may now access your Magento instance at https://${DOMAIN}/"
|