setup 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. #!/bin/bash
  2. set -o errexit
  3. # shellcheck source=../env/db.env
  4. source env/db.env
  5. BASE_URL=${1:-magento2.test}
  6. ES_HOST=elasticsearch
  7. ES_PORT=9200
  8. bin/stop
  9. docker-compose -f docker-compose.yml up -d
  10. [ $? != 0 ] && echo "Failed to start Docker services" && exit
  11. sleep 5 #Ensure containers are started...
  12. echo "Copying all files from host to container..."
  13. rm -rf src/vendor #Clear for step below
  14. bin/copytocontainer --all
  15. bin/clinotty chmod u+x bin/magento
  16. bin/setup-composer-auth
  17. echo "Forcing reinstall of composer deps to ensure perms & reqs..."
  18. bin/clinotty composer global require hirak/prestissimo
  19. bin/clinotty composer update
  20. echo "Waiting for connection to Elasticsearch..."
  21. bin/clinotty timeout 30 bash -c "
  22. until curl --silent --output /dev/null http://$ES_HOST:$ES_PORT/_cat/health?h=st; do
  23. printf '.'
  24. sleep 5
  25. done"
  26. [ $? != 0 ] && echo "Failed to connect to Elasticsearch" && exit
  27. bin/clinotty bin/magento setup:install \
  28. --db-host="$MYSQL_HOST" \
  29. --db-name="$MYSQL_DATABASE" \
  30. --db-user="$MYSQL_USER" \
  31. --db-password="$MYSQL_PASSWORD" \
  32. --base-url=https://"$BASE_URL"/ \
  33. --base-url-secure=https://"$BASE_URL"/ \
  34. --backend-frontname=admin \
  35. --admin-firstname=John \
  36. --admin-lastname=Smith \
  37. --admin-email=john.smith@gmail.com \
  38. --admin-user=john.smith \
  39. --admin-password=password123 \
  40. --language=en_US \
  41. --currency=USD \
  42. --timezone=America/New_York \
  43. --amqp-host=rabbitmq \
  44. --amqp-port=5672 \
  45. --amqp-user=guest \
  46. --amqp-password=guest \
  47. --amqp-virtualhost=/ \
  48. --cache-backend=redis \
  49. --cache-backend-redis-server=redis \
  50. --cache-backend-redis-db=0 \
  51. --page-cache=redis \
  52. --page-cache-redis-server=redis \
  53. --page-cache-redis-db=1 \
  54. --session-save=redis \
  55. --session-save-redis-host=redis \
  56. --session-save-redis-log-level=4 \
  57. --session-save-redis-db=2 \
  58. --search-engine=elasticsearch7 \
  59. --elasticsearch-host=$ES_HOST \
  60. --elasticsearch-port=$ES_PORT \
  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 "Re-indexing with Elasticsearch..."
  68. bin/clinotty bin/magento indexer:reindex
  69. echo "Clearing the cache to apply updates..."
  70. bin/clinotty bin/magento cache:flush
  71. echo "Copying files from container to host after install..."
  72. bin/copyfromcontainer app
  73. bin/copyfromcontainer vendor
  74. echo "Generating SSL certificate..."
  75. bin/setup-ssl "$BASE_URL"
  76. echo "Docker development environment setup complete."
  77. echo "You may now access your Magento instance at https://${BASE_URL}/"