setup 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. # shellcheck source=../env/rabbitmq.env
  10. source env/rabbitmq.env
  11. DOMAIN=${1:-magento.test}
  12. bin/stop
  13. docker-compose -f docker-compose.yml up -d
  14. [ $? != 0 ] && echo "Failed to start Docker services" && exit
  15. bin/clinotty chmod u+x bin/magento
  16. rm -rf src && mkdir 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 connection to RabbitMQ..."
  26. rabbitmqi=10
  27. until [ $rabbitmqi -le 0 ]; do
  28. printf '.'
  29. (( rabbitmqi-- ))
  30. sleep 2
  31. done
  32. bin/clinotty bin/magento setup:install \
  33. --db-host="$MYSQL_HOST" \
  34. --db-name="$MYSQL_DATABASE" \
  35. --db-user="$MYSQL_USER" \
  36. --db-password="$MYSQL_PASSWORD" \
  37. --base-url=https://"$DOMAIN"/ \
  38. --base-url-secure=https://"$DOMAIN"/ \
  39. --backend-frontname="$MAGENTO_ADMIN_FRONTNAME" \
  40. --admin-firstname="$MAGENTO_ADMIN_FIRST_NAME" \
  41. --admin-lastname="$MAGENTO_ADMIN_LAST_NAME" \
  42. --admin-email="$MAGENTO_ADMIN_EMAIL" \
  43. --admin-user="$MAGENTO_ADMIN_USER" \
  44. --admin-password="$MAGENTO_ADMIN_PASSWORD" \
  45. --language="$MAGENTO_LOCALE" \
  46. --currency="$MAGENTO_CURRENCY" \
  47. --timezone="$MAGENTO_TIMEZONE" \
  48. --amqp-host="$RABBITMQ_HOST" \
  49. --amqp-port="$RABBITMQ_PORT" \
  50. --amqp-user="$RABBITMQ_DEFAULT_USER" \
  51. --amqp-password="$RABBITMQ_DEFAULT_PASS" \
  52. --amqp-virtualhost="$RABBITMQ_DEFAULT_VHOST" \
  53. --cache-backend=redis \
  54. --cache-backend-redis-server=redis \
  55. --cache-backend-redis-db=0 \
  56. --page-cache=redis \
  57. --page-cache-redis-server=redis \
  58. --page-cache-redis-db=1 \
  59. --session-save=redis \
  60. --session-save-redis-host=redis \
  61. --session-save-redis-log-level=4 \
  62. --session-save-redis-db=2 \
  63. --search-engine=elasticsearch7 \
  64. --elasticsearch-host=$ES_HOST \
  65. --elasticsearch-port=$ES_PORT \
  66. --use-rewrites=1 \
  67. --no-interaction
  68. echo "Copying files from container to host after install..."
  69. bin/copyfromcontainer --all
  70. echo "Forcing deploy of static content to speed up initial requests..."
  71. bin/clinotty bin/magento setup:static-content:deploy -f
  72. echo "Re-indexing with Elasticsearch..."
  73. bin/clinotty bin/magento indexer:reindex
  74. echo "Setting basic URL and generating SSL certificate..."
  75. bin/setup-domain "${DOMAIN}"
  76. echo "Clearing the cache to apply updates..."
  77. bin/clinotty bin/magento cache:flush
  78. echo "Installing cron, run 'bin/cron start' to enable..."
  79. bin/clinotty bin/magento cron:install
  80. echo "Turning on developer mode..."
  81. bin/clinotty bin/magento deploy:mode:set developer
  82. mv .vscode src/
  83. echo "Docker development environment setup complete."
  84. echo "You may now access your Magento instance at https://${DOMAIN}/"