setup 3.5 KB

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