setup 3.2 KB

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