setup 3.3 KB

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