start 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #!/bin/bash
  2. set -o errexit
  3. # Ref: https://stackoverflow.com/a/51789677/9821321
  4. function parseYaml {
  5. local s='[[:space:]]*' w='[a-zA-Z0-9_]*' fs=$(echo @|tr @ '\034')
  6. sed -ne "s|,$s\]$s\$|]|" \
  7. -e "s|^\($s\)\($w\)$s:$s\[$s\(.*\)$s\]|\1\2:\n\1 - \3|;p" $1 | \
  8. sed -ne "s|,$s}$s\$|}|" \
  9. -e "s|^\($s\)-$s{$s\(.*\)$s}|\1-\n\1 \2|;p" | \
  10. sed -ne "s|^\($s\):|\1|" \
  11. -e "s|^\($s\)-$s[\"']\(.*\)[\"']$s\$|\1$fs$fs\2|p" \
  12. -e "s|^\($s\)-$s\(.*\)$s\$|\1$fs$fs\2|p" \
  13. -e "s|^\($s\)\($w\)$s:$s[\"']\(.*\)[\"']$s\$|\1$fs\2$fs\3|p" \
  14. -e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p" | \
  15. awk -F$fs '{
  16. indent = length($1)/2;
  17. vname[indent] = $2;
  18. for (i in vname) {if (i > indent) {delete vname[i]; idx[i]=0}}
  19. if (length($2) == 0) {vname[indent] = ++idx[indent] };
  20. if (length($3) > 0) {
  21. vn=""; for (i=0; i<indent; i++) {vn = (vn)(vname[i])("_")}
  22. if ("'$2'_" == vn) {
  23. print substr($3 ,1 , match($3,":")-1)
  24. }
  25. }
  26. }'
  27. }
  28. # Check if volume files exist to avoid creating an empty folder
  29. VOLUME_LIST=`parseYaml docker-compose.dev.yml services_app_volumes`
  30. IGNORE_LIST="./src/app/code ./src/m2-hotfixes ./src/patches ./src/var/log ./src/var/report ./src"
  31. IS_VALID=true
  32. # Loop through all files missing from the docker-compose.dev.yml file
  33. for file in $VOLUME_LIST; do
  34. if [ ! -e $file ] && [[ ! " $IGNORE_LIST " =~ " $file " ]]; then
  35. echo "$file: No such file or directory"
  36. IS_VALID=false
  37. fi
  38. done
  39. # Wait to exit until all missing files have been outputted to the user
  40. [ $IS_VALID = false ] && echo "Failed to start docker for missing volume files" && exit
  41. docker-compose -f docker-compose.yml -f docker-compose.dev.yml up -d --remove-orphans "$@"
  42. ## Blackfire support
  43. # ------------------
  44. ## First register the blackfire agent with:
  45. #bin/root blackfire-agent --register --server-id={YOUR_SERVER_ID} --server-token={YOUR_SERVER_TOKEN}
  46. ## Then uncomment the below line (and leave uncommented) to start the agent automatically with bin/start:
  47. #bin/root /etc/init.d/blackfire-agent start
  48. bin/devtools-cli-check
  49. bin/cliq /var/www/.composer-global/vendor/bin/cache-clean.js --quiet --watch &