setup 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. #!/bin/bash
  2. set -o errexit
  3. # shellcheck source=../env/db.env
  4. source env/db.env
  5. # shellcheck source=../env/elasticsearch.env
  6. source env/elasticsearch.env
  7. # shellcheck source=../env/magento.env
  8. source env/magento.env
  9. DOMAIN=${1:-magento.test}
  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 && mkdir src
  15. echo "Waiting for connection to Elasticsearch..."
  16. bin/clinotty timeout 100 bash -c "
  17. until curl --silent --output /dev/null http://$ES_HOST:$ES_PORT/_cat/health?h=st; do
  18. printf '.'
  19. sleep 2
  20. done"
  21. [ $? != 0 ] && echo "Failed to connect to Elasticsearch" && exit
  22. echo ""
  23. echo "Waiting for connection to RabbitMQ..."
  24. rabbitmqi=4
  25. until [ $rabbitmqi -le 0 ]; do
  26. printf '.'
  27. let rabbitmqi--
  28. sleep 2
  29. done
  30. bin/clinotty bin/magento setup:install \
  31. --db-host="$MYSQL_HOST" \
  32. --db-name="$MYSQL_DATABASE" \
  33. --db-user="$MYSQL_USER" \
  34. --db-password="$MYSQL_PASSWORD" \
  35. --base-url=https://"$DOMAIN"/ \
  36. --base-url-secure=https://"$DOMAIN"/ \
  37. --backend-frontname="$MAGENTO_ADMIN_FRONTNAME" \
  38. --admin-firstname="$MAGENTO_ADMIN_FIRST_NAME" \
  39. --admin-lastname="$MAGENTO_ADMIN_LAST_NAME" \
  40. --admin-email="$MAGENTO_ADMIN_EMAIL" \
  41. --admin-user="$MAGENTO_ADMIN_USER" \
  42. --admin-password="$MAGENTO_ADMIN_PASSWORD" \
  43. --language="$MAGENTO_LOCALE" \
  44. --currency="$MAGENTO_CURRENCY" \
  45. --timezone="$MAGENTO_TIMEZONE" \
  46. --amqp-host=rabbitmq \
  47. --amqp-port=5672 \
  48. --amqp-user=guest \
  49. --amqp-password=guest \
  50. --amqp-virtualhost=/ \
  51. --cache-backend=redis \
  52. --cache-backend-redis-server=redis \
  53. --cache-backend-redis-db=0 \
  54. --page-cache=redis \
  55. --page-cache-redis-server=redis \
  56. --page-cache-redis-db=1 \
  57. --session-save=redis \
  58. --session-save-redis-host=redis \
  59. --session-save-redis-log-level=4 \
  60. --session-save-redis-db=2 \
  61. --search-engine=elasticsearch7 \
  62. --elasticsearch-host=$ES_HOST \
  63. --elasticsearch-port=$ES_PORT \
  64. --use-rewrites=1
  65. echo "Copying files from container to host after install..."
  66. bin/copyfromcontainer --all
  67. echo "Forcing deploy of static content to speed up initial requests..."
  68. bin/clinotty bin/magento setup:static-content:deploy -f
  69. echo "Re-indexing with Elasticsearch..."
  70. bin/clinotty bin/magento indexer:reindex
  71. echo "Setting basic URL and generating SSL certificate..."
  72. bin/setup-domain "${DOMAIN}"
  73. echo "Clearing the cache to apply updates..."
  74. bin/clinotty bin/magento cache:flush
  75. echo "Ensuring Composer auth.json is setup..."
  76. bin/setup-composer-auth
  77. echo "Installing cron (see docker-compose.yml to enable)..."
  78. bin/magento cron:install
  79. echo "Turning on developer mode.."
  80. bin/clinotty bin/magento deploy:mode:set developer
  81. mv .vscode src/
  82. echo "Docker development environment setup complete."
  83. echo "You may now access your Magento instance at https://${DOMAIN}/"