setup 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. #!/bin/bash
  2. source env/db.env
  3. BASE_URL=${1:-magento2.test}
  4. bin/stop
  5. docker-compose -f docker-compose.yml up -d
  6. [ $? != 0 ] && echo "Failed to start Docker services" && exit
  7. sleep 5 #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 update
  42. bin/clinotty bin/magento setup:install \
  43. --db-host=$MYSQL_HOST \
  44. --db-name=$MYSQL_DATABASE \
  45. --db-user=$MYSQL_USER \
  46. --db-password=$MYSQL_PASSWORD \
  47. --base-url=https://$BASE_URL/ \
  48. --base-url-secure=https://$BASE_URL/ \
  49. --backend-frontname=admin \
  50. --admin-firstname=John \
  51. --admin-lastname=Smith \
  52. --admin-email=john.smith@gmail.com \
  53. --admin-user=john.smith \
  54. --admin-password=password123 \
  55. --language=en_US \
  56. --currency=USD \
  57. --timezone=America/New_York \
  58. --amqp-host=rabbitmq \
  59. --amqp-port=5672 \
  60. --amqp-user=guest \
  61. --amqp-password=guest \
  62. --amqp-virtualhost=/ \
  63. --cache-backend=redis \
  64. --cache-backend-redis-server=redis \
  65. --cache-backend-redis-db=0 \
  66. --page-cache=redis \
  67. --page-cache-redis-server=redis \
  68. --page-cache-redis-db=1 \
  69. --session-save=redis \
  70. --session-save-redis-host=redis \
  71. --session-save-redis-log-level=4 \
  72. --session-save-redis-db=2 \
  73. --search-engine=elasticsearch7 \
  74. --elasticsearch-host=elasticsearch \
  75. --use-rewrites=1
  76. echo "Turning on developer mode.."
  77. bin/clinotty bin/magento deploy:mode:set developer
  78. bin/clinotty bin/magento indexer:reindex
  79. echo "Forcing deploy of static content to speed up initial requests..."
  80. bin/clinotty bin/magento setup:static-content:deploy -f
  81. echo "Re-indexing with Elasticsearch..."
  82. bin/clinotty bin/magento indexer:reindex
  83. echo "Clearing the cache to apply updates..."
  84. bin/clinotty bin/magento cache:flush
  85. echo "Copying files from container to host after install..."
  86. bin/copyfromcontainer app
  87. bin/copyfromcontainer vendor
  88. echo "Generating SSL certificate..."
  89. bin/setup-ssl $BASE_URL
  90. echo "Docker development environment setup complete."
  91. echo "You may now access your Magento instance at https://${BASE_URL}/"