setup 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. #!/bin/bash
  2. BASE_URL=${1:-magento2.test}
  3. bin/stop
  4. docker-compose -f docker-compose.yml up -d
  5. sleep 1 #Ensure containers are started...
  6. echo "Copying all files from host to container..."
  7. rm -rf src/vendor #Clear for step below
  8. bin/copytocontainer --all
  9. bin/clinotty chmod u+x bin/magento
  10. if hash composer 2>/dev/null; then
  11. PUBLIC_KEY="$(composer config -gl | grep '\[http-basic.repo.magento.com.username\]' | cut -c40-)"
  12. PRIVATE_KEY="$(composer config -gl | grep '\[http-basic.repo.magento.com.password\]' | cut -c40-)"
  13. fi
  14. if [ -z "$PUBLIC_KEY" ] || [ -z "$PRIVATE_KEY" ]; then
  15. exec < /dev/tty
  16. echo
  17. echo
  18. echo " Authentication required (repo.magento.com, public_key and private_key):"
  19. read -p " Username: " PUBLIC_KEY
  20. read -p " Password: " PRIVATE_KEY
  21. echo
  22. if [ -n "$PUBLIC_KEY" ] && [ -n "$PRIVATE_KEY" ] && hash composer 2>/dev/null; then
  23. read -p " Add authentication information to host composer config? y/n: " ADD_AUTH
  24. echo
  25. if [[ $ADD_AUTH =~ ^[Yy]$ ]]; then
  26. composer global config http-basic.repo.magento.com $PUBLIC_KEY $PRIVATE_KEY
  27. fi
  28. ADD_AUTH=''
  29. fi
  30. exec <&-
  31. fi
  32. if [ -n "$PUBLIC_KEY" ] && [ -n "$PRIVATE_KEY" ]; then
  33. bin/clinotty composer config http-basic.repo.magento.com $PUBLIC_KEY $PRIVATE_KEY
  34. PUBLIC_KEY=''
  35. PRIVATE_KEY=''
  36. fi
  37. echo "Forcing reinstall of composer deps to ensure perms & reqs..."
  38. bin/clinotty composer global require hirak/prestissimo
  39. bin/clinotty composer update
  40. bin/clinotty bin/magento setup:install \
  41. --db-host=db \
  42. --db-name=magento \
  43. --db-user=magento \
  44. --db-password=magento \
  45. --base-url=https://$BASE_URL/ \
  46. --admin-firstname=John \
  47. --admin-lastname=Smith \
  48. --admin-email=john.smith@gmail.com \
  49. --admin-user=john.smith \
  50. --admin-password=password123 \
  51. --language=en_US \
  52. --currency=USD \
  53. --timezone=America/New_York \
  54. --amqp-host=rabbitmq \
  55. --amqp-port=5672 \
  56. --amqp-user=guest \
  57. --amqp-password=guest \
  58. --amqp-virtualhost=/ \
  59. --search-engine=elasticsearch7 \
  60. --elasticsearch-host=elasticsearch \
  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 "Re-indexing with Elasticsearch..."
  74. bin/clinotty bin/magento indexer:reindex
  75. echo "Clearing the cache to apply updates..."
  76. bin/clinotty bin/magento cache:flush
  77. echo "Copying files from container to host after install..."
  78. bin/copyfromcontainer app
  79. bin/copyfromcontainer vendor
  80. echo "Generating SSL certificate..."
  81. bin/setup-ssl $BASE_URL
  82. echo "Docker development environment setup complete."
  83. echo "You may now access your Magento instance at https://${BASE_URL}/"