setup 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #!/bin/bash
  2. BASE_URL=${1:-magento2.test}
  3. bin/stop
  4. # get rid of vertex/module-tax, not required and causes checksum errors on composer install
  5. # https://github.com/markshust/docker-magento/issues/135
  6. # prevent double or more insertion
  7. if ! grep -qF '"replace": { "vertex/module-tax": "*" }' src/composer.json; then
  8. sed -e 's/"conflict": {/"replace": { "vertex\/module-tax": "*" },\ "conflict": {/' src/composer.json > composer.json && mv composer.json src/composer.json
  9. fi
  10. docker-compose -f docker-compose.yml up -d
  11. sleep 1 #Ensure containers are started...
  12. echo "Copying all files from host to container..."
  13. rm -rf src/vendor #Clear for step below
  14. bin/copytocontainer --all
  15. bin/clinotty chmod u+x bin/magento
  16. echo "Forcing reinstall of composer deps to ensure perms & reqs..."
  17. bin/clinotty composer install
  18. bin/clinotty bin/magento setup:install \
  19. --db-host=db \
  20. --db-name=magento \
  21. --db-user=magento \
  22. --db-password=magento \
  23. --base-url=https://$BASE_URL/ \
  24. --admin-firstname=John \
  25. --admin-lastname=Smith \
  26. --admin-email=john.smith@gmail.com \
  27. --admin-user=john.smith \
  28. --admin-password=password123 \
  29. --language=en_US \
  30. --currency=USD \
  31. --timezone=America/New_York \
  32. --use-rewrites=1
  33. echo "Turning on developer mode.."
  34. bin/clinotty bin/magento deploy:mode:set developer
  35. bin/clinotty bin/magento indexer:reindex
  36. echo "Forcing deploy of static content to speed up initial requests..."
  37. bin/clinotty bin/magento setup:static-content:deploy -f
  38. echo "Enabling redis for cache..."
  39. bin/clinotty bin/magento setup:config:set --no-interaction --cache-backend=redis --cache-backend-redis-server=redis --cache-backend-redis-db=0
  40. echo "Enabling Redis for session..."
  41. bin/clinotty bin/magento setup:config:set --no-interaction --session-save=redis --session-save-redis-host=redis --session-save-redis-log-level=4 --session-save-redis-db=1
  42. echo "Clearing the cache for good measure..."
  43. bin/clinotty bin/magento cache:flush
  44. echo "Copying files from container to host after install..."
  45. bin/copyfromcontainer app
  46. bin/copyfromcontainer vendor
  47. echo "Restarting containers with host bind mounts for dev..."
  48. bin/restart
  49. echo "Docker development environment setup complete."
  50. echo "You may now access your Magento instance at https://${BASE_URL}/"