setup 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. DOMAIN=${1:-magento.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. bin/clinotty chmod u+x bin/magento
  14. rm -rf src
  15. mkdir src
  16. cp -R .vscode src
  17. echo "Waiting for connection to Elasticsearch..."
  18. bin/clinotty timeout 100 bash -c "
  19. until curl --silent --output /dev/null http://$ES_HOST:$ES_PORT/_cat/health?h=st; do
  20. printf '.'
  21. sleep 2
  22. done"
  23. [ $? != 0 ] && echo "Failed to connect to Elasticsearch" && exit
  24. echo ""
  25. echo "Waiting for Elasticsearch container to get initialized..."
  26. sleep 5
  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://"$DOMAIN"/ \
  33. --base-url-secure=https://"$DOMAIN"/ \
  34. --backend-frontname="$MAGENTO_ADMIN_FRONTNAME" \
  35. --admin-firstname="$MAGENTO_ADMIN_FIRST_NAME" \
  36. --admin-lastname="$MAGENTO_ADMIN_LAST_NAME" \
  37. --admin-email="$MAGENTO_ADMIN_EMAIL" \
  38. --admin-user="$MAGENTO_ADMIN_USER" \
  39. --admin-password="$MAGENTO_ADMIN_PASSWORD" \
  40. --language="$MAGENTO_LOCALE" \
  41. --currency="$MAGENTO_CURRENCY" \
  42. --timezone="$MAGENTO_TIMEZONE" \
  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 "Copying files from container to host after install..."
  63. bin/copyfromcontainer --all
  64. echo "Forcing deploy of static content to speed up initial requests..."
  65. bin/clinotty bin/magento setup:static-content:deploy -f
  66. echo "Re-indexing with Elasticsearch..."
  67. bin/clinotty bin/magento indexer:reindex
  68. echo "Setting basic URL and generating SSL certificate..."
  69. bin/setup-domain "${DOMAIN}"
  70. echo "Clearing the cache to apply updates..."
  71. bin/clinotty bin/magento cache:flush
  72. echo "Ensuring Composer auth.json is setup..."
  73. bin/setup-composer-auth
  74. echo "Installing cron (see docker-compose.yml to enable)..."
  75. bin/magento cron:install
  76. echo "Turning on developer mode.."
  77. bin/clinotty bin/magento deploy:mode:set developer
  78. echo "Docker development environment setup complete."
  79. echo "You may now access your Magento instance at https://${DOMAIN}/"