setup 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #!/bin/bash
  2. set -o errexit
  3. # shellcheck source=../env/db.env
  4. source env/db.env
  5. # shellcheck source=../env/magento.env
  6. source env/magento.env
  7. BASE_URL=${1:-magento2.test}
  8. ES_HOST=elasticsearch
  9. ES_PORT=9200
  10. bin/stop
  11. docker-compose -f docker-compose.yml up -d
  12. [ $? != 0 ] && echo "Failed to start Docker services" && exit
  13. sleep 5 #Ensure containers are started...
  14. bin/clinotty chmod u+x bin/magento
  15. mv .vscode src/
  16. echo "Waiting for connection to Elasticsearch..."
  17. bin/clinotty timeout 30 bash -c "
  18. until curl --silent --output /dev/null http://$ES_HOST:$ES_PORT/_cat/health?h=st; do
  19. printf '.'
  20. sleep 5
  21. done"
  22. [ $? != 0 ] && echo "Failed to connect to Elasticsearch" && exit
  23. bin/clinotty bin/magento setup:install \
  24. --db-host="$MYSQL_HOST" \
  25. --db-name="$MYSQL_DATABASE" \
  26. --db-user="$MYSQL_USER" \
  27. --db-password="$MYSQL_PASSWORD" \
  28. --base-url=https://"$BASE_URL"/ \
  29. --base-url-secure=https://"$BASE_URL"/ \
  30. --backend-frontname="$MAGENTO_ADMIN_FRONTNAME" \
  31. --admin-firstname="$MAGENTO_ADMIN_FIRST_NAME" \
  32. --admin-lastname="$MAGENTO_ADMIN_LAST_NAME" \
  33. --admin-email="$MAGENTO_ADMIN_EMAIL" \
  34. --admin-user="$MAGENTO_ADMIN_USER" \
  35. --admin-password="$MAGENTO_ADMIN_PASSWORD" \
  36. --language="$MAGENTO_LOCALE" \
  37. --currency="$MAGENTO_CURRENCY" \
  38. --timezone="$MAGENTO_TIMEZONE" \
  39. --amqp-host=rabbitmq \
  40. --amqp-port=5672 \
  41. --amqp-user=guest \
  42. --amqp-password=guest \
  43. --amqp-virtualhost=/ \
  44. --cache-backend=redis \
  45. --cache-backend-redis-server=redis \
  46. --cache-backend-redis-db=0 \
  47. --page-cache=redis \
  48. --page-cache-redis-server=redis \
  49. --page-cache-redis-db=1 \
  50. --session-save=redis \
  51. --session-save-redis-host=redis \
  52. --session-save-redis-log-level=4 \
  53. --session-save-redis-db=2 \
  54. --search-engine=elasticsearch7 \
  55. --elasticsearch-host=$ES_HOST \
  56. --elasticsearch-port=$ES_PORT \
  57. --use-rewrites=1
  58. echo "Copying files from container to host after install..."
  59. bin/copyfromcontainer --all
  60. echo "Turning on developer mode.."
  61. bin/clinotty bin/magento deploy:mode:set developer
  62. echo "Forcing deploy of static content to speed up initial requests..."
  63. bin/clinotty bin/magento setup:static-content:deploy -f
  64. echo "Re-indexing with Elasticsearch..."
  65. bin/clinotty bin/magento indexer:reindex
  66. echo "Clearing the cache to apply updates..."
  67. bin/clinotty bin/magento cache:flush
  68. echo "Generating SSL certificate..."
  69. bin/setup-ssl "$BASE_URL"
  70. echo "Docker development environment setup complete."
  71. echo "You may now access your Magento instance at https://${BASE_URL}/"