setup 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. #!/bin/bash
  2. set -o errexit
  3. MEM_BYTES=$(docker info -f '{{.MemTotal}}')
  4. MEM_MB=$(( MEM_BYTES / 1000000 ))
  5. (( MEM_MB >= 6000 )) || {
  6. echo 'There must be at least 6GB of RAM allocated to Docker to continue.' >&2
  7. exit 1
  8. }
  9. # shellcheck source=../env/db.env
  10. source env/db.env
  11. # shellcheck source=../env/elasticsearch.env
  12. source env/elasticsearch.env
  13. # shellcheck source=../env/opensearch.env
  14. source env/opensearch.env
  15. # shellcheck source=../env/magento.env
  16. source env/magento.env
  17. # shellcheck source=../env/rabbitmq.env
  18. source env/rabbitmq.env
  19. DOMAIN=${1:-magento.test}
  20. bin/stop
  21. bin/start --no-dev
  22. [ $? != 0 ] && echo "Failed to start Docker services" && exit
  23. bin/clinotty chmod u+x bin/magento
  24. rm -rf src && mkdir src
  25. echo "Adding Magento modules to Composer allow-plugins directive..."
  26. bin/clinotty composer config --no-plugins allow-plugins.magento/magento-composer-installer true
  27. bin/clinotty composer config --no-plugins allow-plugins.magento/inventory-composer-installer true
  28. bin/clinotty composer config --no-plugins allow-plugins.laminas/laminas-dependency-plugin true
  29. bin/clinotty bin/magento setup:install \
  30. --db-host="$MYSQL_HOST" \
  31. --db-name="$MYSQL_DATABASE" \
  32. --db-user="$MYSQL_USER" \
  33. --db-password="$MYSQL_PASSWORD" \
  34. --base-url=https://"$DOMAIN"/ \
  35. --base-url-secure=https://"$DOMAIN"/ \
  36. --backend-frontname="$MAGENTO_ADMIN_FRONTNAME" \
  37. --admin-firstname="$MAGENTO_ADMIN_FIRST_NAME" \
  38. --admin-lastname="$MAGENTO_ADMIN_LAST_NAME" \
  39. --admin-email="$MAGENTO_ADMIN_EMAIL" \
  40. --admin-user="$MAGENTO_ADMIN_USER" \
  41. --admin-password="$MAGENTO_ADMIN_PASSWORD" \
  42. --language="$MAGENTO_LOCALE" \
  43. --currency="$MAGENTO_CURRENCY" \
  44. --timezone="$MAGENTO_TIMEZONE" \
  45. --amqp-host="$RABBITMQ_HOST" \
  46. --amqp-port="$RABBITMQ_PORT" \
  47. --amqp-user="$RABBITMQ_DEFAULT_USER" \
  48. --amqp-password="$RABBITMQ_DEFAULT_PASS" \
  49. --amqp-virtualhost="$RABBITMQ_DEFAULT_VHOST" \
  50. --cache-backend=redis \
  51. --cache-backend-redis-server=redis \
  52. --cache-backend-redis-db=0 \
  53. --page-cache=redis \
  54. --page-cache-redis-server=redis \
  55. --page-cache-redis-db=1 \
  56. --session-save=redis \
  57. --session-save-redis-host=redis \
  58. --session-save-redis-log-level=4 \
  59. --session-save-redis-db=2 \
  60. --elasticsearch-host=$OPENSEARCH_HOST \
  61. --elasticsearch-port=$OPENSEARCH_PORT \
  62. --use-rewrites=1 \
  63. --no-interaction
  64. echo "Copying files from container to host after install..."
  65. bin/copyfromcontainer --all
  66. echo "Forcing deploy of static content to speed up initial requests..."
  67. bin/clinotty bin/magento setup:static-content:deploy -f
  68. echo "Re-indexing with Elasticsearch..."
  69. bin/clinotty bin/magento indexer:reindex
  70. echo "Setting basic URL and generating SSL certificate..."
  71. bin/setup-domain "${DOMAIN}"
  72. echo "Fixing owner and permissions..."
  73. bin/fixowns
  74. bin/fixperms
  75. echo "Clearing the cache to apply updates..."
  76. bin/clinotty bin/magento cache:flush
  77. echo "Installing cron, run 'bin/cron start' to enable..."
  78. bin/clinotty bin/magento cron:install
  79. echo "Turning on developer mode..."
  80. bin/clinotty bin/magento deploy:mode:set developer
  81. cp -r .vscode src/
  82. echo "Docker development environment setup complete."
  83. echo "You may now access your Magento instance at https://${DOMAIN}/"