setup 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #!/bin/bash
  2. set -o errexit
  3. MEM=$(docker info | grep "Total Memory" | cut -d':' -f2 | xargs | sed s/GiB//)
  4. # Docker reports RAM 0.2 less than what it is actually set to
  5. (( $(echo "$MEM < 5.8" | bc -l) )) && echo "There must be at least 6GB of RAM allocated to Docker to continue." && exit
  6. # shellcheck source=../env/db.env
  7. source env/db.env
  8. # shellcheck source=../env/elasticsearch.env
  9. source env/elasticsearch.env
  10. # shellcheck source=../env/magento.env
  11. source env/magento.env
  12. # shellcheck source=../env/rabbitmq.env
  13. source env/rabbitmq.env
  14. DOMAIN=${1:-magento.test}
  15. bin/stop
  16. bin/docker-compose --no-dev up -d
  17. [ $? != 0 ] && echo "Failed to start Docker services" && exit
  18. bin/clinotty chmod u+x bin/magento
  19. rm -rf src && mkdir src
  20. echo "Adding Magento modules to Composer allow-plugins directive..."
  21. bin/clinotty composer config --no-plugins allow-plugins.magento/magento-composer-installer true
  22. bin/clinotty composer config --no-plugins allow-plugins.magento/inventory-composer-installer true
  23. bin/clinotty composer config --no-plugins allow-plugins.laminas/laminas-dependency-plugin true
  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_HOST" \
  41. --amqp-port="$RABBITMQ_PORT" \
  42. --amqp-user="$RABBITMQ_DEFAULT_USER" \
  43. --amqp-password="$RABBITMQ_DEFAULT_PASS" \
  44. --amqp-virtualhost="$RABBITMQ_DEFAULT_VHOST" \
  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. --no-interaction
  60. echo "Copying files from container to host after install..."
  61. bin/copyfromcontainer --all
  62. echo "Forcing deploy of static content to speed up initial requests..."
  63. bin/clinotty bin/magento setup:static-content:deploy -f
  64. echo "Re-indexing with Elasticsearch..."
  65. bin/clinotty bin/magento indexer:reindex
  66. echo "Setting basic URL and generating SSL certificate..."
  67. bin/setup-domain "${DOMAIN}"
  68. echo "Fixing owner and permissions..."
  69. bin/fixowns
  70. bin/fixperms
  71. echo "Clearing the cache to apply updates..."
  72. bin/clinotty bin/magento cache:flush
  73. echo "Installing cron, run 'bin/cron start' to enable..."
  74. bin/clinotty bin/magento cron:install
  75. echo "Turning on developer mode..."
  76. bin/clinotty bin/magento deploy:mode:set developer
  77. cp -r .vscode src/
  78. echo "Docker development environment setup complete."
  79. echo "You may now access your Magento instance at https://${DOMAIN}/"