setup 3.2 KB

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