setup 2.7 KB

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