setup 2.6 KB

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