setup 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. #!/bin/bash
  2. BASE_URL=${1:-magento2.test}
  3. bin/stop
  4. # fix for invalid google-shopping-api checksum contained in archive installs (temporary fix until nexcess archive is patched)
  5. sed -e 's/5f5929ef9f2ec4ca048a2add261d22c92807630f/ce31e720d60451784b9fdb3769e43e149f50d436/' src/composer.lock > composer.lock && mv composer.lock src/composer.lock
  6. docker-compose -f docker-compose.yml up -d
  7. [ $? != 0 ] && echo "Failed to start Docker services" && exit
  8. sleep 5 #Ensure containers are started...
  9. echo "Copying all files from host to container..."
  10. rm -rf src/vendor #Clear for step below
  11. bin/copytocontainer --all
  12. bin/clinotty chmod u+x bin/magento
  13. if hash composer 2>/dev/null; then
  14. PUBLIC_KEY="$(composer config -gl | grep '\[http-basic.repo.magento.com.username\]' | cut -c40-)"
  15. PRIVATE_KEY="$(composer config -gl | grep '\[http-basic.repo.magento.com.password\]' | cut -c40-)"
  16. fi
  17. if [ -z "$PUBLIC_KEY" ] || [ -z "$PRIVATE_KEY" ]; then
  18. exec < /dev/tty
  19. echo
  20. echo
  21. echo " Authentication required (repo.magento.com, public_key and private_key):"
  22. read -p " Username: " PUBLIC_KEY
  23. read -p " Password: " PRIVATE_KEY
  24. echo
  25. if [ -n "$PUBLIC_KEY" ] && [ -n "$PRIVATE_KEY" ] && hash composer 2>/dev/null; then
  26. read -p " Add authentication information to host composer config? y/n: " ADD_AUTH
  27. echo
  28. if [[ $ADD_AUTH =~ ^[Yy]$ ]]; then
  29. composer global config http-basic.repo.magento.com $PUBLIC_KEY $PRIVATE_KEY
  30. fi
  31. ADD_AUTH=''
  32. fi
  33. exec <&-
  34. fi
  35. if [ -n "$PUBLIC_KEY" ] && [ -n "$PRIVATE_KEY" ]; then
  36. bin/clinotty composer config http-basic.repo.magento.com $PUBLIC_KEY $PRIVATE_KEY
  37. PUBLIC_KEY=''
  38. PRIVATE_KEY=''
  39. fi
  40. echo "Forcing reinstall of composer deps to ensure perms & reqs..."
  41. bin/clinotty composer global require hirak/prestissimo
  42. bin/clinotty composer install
  43. bin/clinotty bin/magento setup:install \
  44. --db-host=db \
  45. --db-name=magento \
  46. --db-user=magento \
  47. --db-password=magento \
  48. --base-url=https://$BASE_URL/ \
  49. --admin-firstname=John \
  50. --admin-lastname=Smith \
  51. --admin-email=john.smith@gmail.com \
  52. --admin-user=john.smith \
  53. --admin-password=password123 \
  54. --language=en_US \
  55. --currency=USD \
  56. --timezone=America/New_York \
  57. --amqp-host=rabbitmq \
  58. --amqp-port=5672 \
  59. --amqp-user=guest \
  60. --amqp-password=guest \
  61. --amqp-virtualhost=/ \
  62. --use-rewrites=1
  63. echo "Turning on developer mode.."
  64. bin/clinotty bin/magento deploy:mode:set developer
  65. bin/clinotty bin/magento indexer:reindex
  66. echo "Forcing deploy of static content to speed up initial requests..."
  67. bin/clinotty bin/magento setup:static-content:deploy -f
  68. echo "Enabling Redis for cache..."
  69. bin/clinotty bin/magento setup:config:set --no-interaction --cache-backend=redis --cache-backend-redis-server=redis --cache-backend-redis-db=0
  70. echo "Enabling Redis for Full Page Cache..."
  71. bin/clinotty bin/magento setup:config:set --no-interaction --page-cache=redis --page-cache-redis-server=redis --page-cache-redis-db=1
  72. echo "Enabling Redis for session..."
  73. 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
  74. echo "Enabling Elasticsearch..."
  75. bin/clinotty bin/magento config:set catalog/search/elasticsearch7_server_hostname elasticsearch
  76. echo "Re-indexing with Elasticsearch..."
  77. bin/clinotty bin/magento indexer:reindex
  78. echo "Clearing the cache to apply updates..."
  79. bin/clinotty bin/magento cache:flush
  80. echo "Copying files from container to host after install..."
  81. bin/copyfromcontainer app
  82. bin/copyfromcontainer vendor
  83. echo "Generating SSL certificate..."
  84. bin/setup-ssl $BASE_URL
  85. echo "Docker development environment setup complete."
  86. echo "You may now access your Magento instance at https://${BASE_URL}/"