123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- #!/bin/bash
- BASE_URL=${1:-magento2.test}
- bin/stop
- # fix for invalid google-shopping-api checksum contained in archive installs (temporary fix until nexcess archive is patched)
- sed -e 's/5f5929ef9f2ec4ca048a2add261d22c92807630f/ce31e720d60451784b9fdb3769e43e149f50d436/' src/composer.lock > composer.lock && mv composer.lock src/composer.lock
- docker-compose -f docker-compose.yml up -d
- sleep 1 #Ensure containers are started...
- curl -O https://files.magerun.net/n98-magerun2.phar
- chmod +x n98-magerun2.phar
- mv n98-magerun2.phar src/bin/n98-magerun2.phar
- echo "Copying all files from host to container..."
- rm -rf src/vendor #Clear for step below
- bin/copytocontainer --all
- bin/clinotty chmod u+x bin/magento
- if hash composer 2>/dev/null; then
- PUBLIC_KEY="$(composer config -gl | grep '\[http-basic.repo.magento.com.username\]' | cut -c40-)"
- PRIVATE_KEY="$(composer config -gl | grep '\[http-basic.repo.magento.com.password\]' | cut -c40-)"
- fi
- if [ -z "$PUBLIC_KEY" ] || [ -z "$PRIVATE_KEY" ]; then
- exec < /dev/tty
- echo
- echo
- echo " Authentication required (repo.magento.com, public_key and private_key):"
- read -p " Username: " PUBLIC_KEY
- read -p " Password: " PRIVATE_KEY
- echo
- if [ -n "$PUBLIC_KEY" ] && [ -n "$PRIVATE_KEY" ] && hash composer 2>/dev/null; then
- read -p " Add authentication information to host composer config? y/n: " ADD_AUTH
- echo
- if [[ $ADD_AUTH =~ ^[Yy]$ ]]; then
- composer global config http-basic.repo.magento.com $PUBLIC_KEY $PRIVATE_KEY
- fi
- ADD_AUTH=''
- fi
- exec <&-
- fi
- if [ -n "$PUBLIC_KEY" ] && [ -n "$PRIVATE_KEY" ]; then
- bin/clinotty composer config http-basic.repo.magento.com $PUBLIC_KEY $PRIVATE_KEY
- PUBLIC_KEY=''
- PRIVATE_KEY=''
- fi
- echo "Forcing reinstall of composer deps to ensure perms & reqs..."
- bin/clinotty composer global require hirak/prestissimo
- bin/clinotty composer install
- bin/clinotty bin/magento setup:install \
- --db-host=db \
- --db-name=magento \
- --db-user=magento \
- --db-password=magento \
- --base-url=https://$BASE_URL/ \
- --admin-firstname=John \
- --admin-lastname=Smith \
- --admin-email=john.smith@gmail.com \
- --admin-user=john.smith \
- --admin-password=password123 \
- --language=en_US \
- --currency=USD \
- --timezone=America/New_York \
- --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 "Enabling Redis for cache..."
- bin/clinotty bin/magento setup:config:set --no-interaction --cache-backend=redis --cache-backend-redis-server=redis --cache-backend-redis-db=0
- echo "Enabling Redis for Full Page Cache..."
- bin/clinotty bin/magento setup:config:set --no-interaction --page-cache=redis --page-cache-redis-server=redis --page-cache-redis-db=1
- echo "Enabling Redis for session..."
- bin/clinotty bin/magento setup:config:set --no-interaction --session-save=redis --session-save-redis-host=redis --session-save-redis-log-level=4 --session-save-redis-db=2
- echo "Clearing the cache for good measure..."
- bin/clinotty bin/magento cache:flush
- echo "Copying files from container to host after install..."
- bin/copyfromcontainer app
- bin/copyfromcontainer vendor
- echo "Restarting containers with host bind mounts for dev..."
- bin/restart
- echo "Docker development environment setup complete."
- echo "You may now access your Magento instance at https://${BASE_URL}/"
|