2
0

setup 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. #!/bin/bash
  2. set -o errexit
  3. # shellcheck source=../env/db.env
  4. source env/db.env
  5. # shellcheck source=../env/magento.env
  6. source env/magento.env
  7. BASE_URL=${1:-magento2.test}
  8. ES_HOST=elasticsearch
  9. ES_PORT=9200
  10. bin/stop
  11. docker-compose -f docker-compose.yml up -d
  12. [ $? != 0 ] && echo "Failed to start Docker services" && exit
  13. sleep 5 #Ensure containers are started...
  14. echo "Copying all files from host to container..."
  15. rm -rf src/vendor #Clear for step below
  16. bin/copytocontainer --all
  17. bin/clinotty chmod u+x bin/magento
  18. bin/setup-composer-auth
  19. echo "Forcing reinstall of composer deps to ensure perms & reqs..."
  20. bin/clinotty composer global require hirak/prestissimo
  21. bin/clinotty composer update
  22. echo "Waiting for connection to Elasticsearch..."
  23. bin/clinotty timeout 30 bash -c "
  24. until curl --silent --output /dev/null http://$ES_HOST:$ES_PORT/_cat/health?h=st; do
  25. printf '.'
  26. sleep 5
  27. done"
  28. [ $? != 0 ] && echo "Failed to connect to Elasticsearch" && exit
  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://"$BASE_URL"/ \
  35. --base-url-secure=https://"$BASE_URL"/ \
  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 \
  46. --amqp-port=5672 \
  47. --amqp-user=guest \
  48. --amqp-password=guest \
  49. --amqp-virtualhost=/ \
  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. --search-engine=elasticsearch7 \
  61. --elasticsearch-host=$ES_HOST \
  62. --elasticsearch-port=$ES_PORT \
  63. --use-rewrites=1
  64. echo "Turning on developer mode.."
  65. bin/clinotty bin/magento deploy:mode:set developer
  66. bin/clinotty bin/magento indexer:reindex
  67. echo "Forcing deploy of static content to speed up initial requests..."
  68. bin/clinotty bin/magento setup:static-content:deploy -f
  69. echo "Re-indexing with Elasticsearch..."
  70. bin/clinotty bin/magento indexer:reindex
  71. echo "Clearing the cache to apply updates..."
  72. bin/clinotty bin/magento cache:flush
  73. echo "Copying files from container to host after install..."
  74. bin/copyfromcontainer app
  75. bin/copyfromcontainer vendor
  76. echo "Generating SSL certificate..."
  77. bin/setup-ssl "$BASE_URL"
  78. echo "Docker development environment setup complete."
  79. echo "You may now access your Magento instance at https://${BASE_URL}/"