setup 3.4 KB

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