123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- #!/usr/bin/env bash
- set -o errexit
- MEM=$(docker info | grep "Total Memory" | cut -d':' -f2 | xargs | sed s/GiB//)
- # Docker reports RAM 0.2 less than what it is actually set to
- (( $(echo "$MEM < 5.7" | bc -l) )) && echo "There must be at least 6GB of RAM allocated to Docker to continue." && exit
- if [ "$1" == "--no-dev" ]; then
- bin/docker-compose --no-dev up -d --remove-orphans "${@:2}"
- exit $?
- fi
- # Ref: https://stackoverflow.com/a/51789677/9821321
- function parseYaml {
- local s
- local w
- local fs
- s='[[:space:]]*'
- w='[a-zA-Z0-9_]*'
- fs=$(echo @|tr @ '\034')
- sed -ne "s|,$s\]$s\$|]|" \
- -e "s|^\($s\)\($w\)$s:$s\[$s\(.*\)$s\]|\1\2:\n\1 - \3|;p" "$1" | \
- sed -ne "s|,$s}$s\$|}|" \
- -e "s|^\($s\)-$s{$s\(.*\)$s}|\1-\n\1 \2|;p" | \
- sed -ne "s|^\($s\):|\1|" \
- -e "s|^\($s\)-$s{[\"']\(.*\)[\"']}$s\$|\1$fs$fs\2|p" \
- -e "s|^\($s\)-$s\(.*\)$s\$|\1$fs$fs\2|p" \
- -e "s|^\($s\)\($w\)$s:$s{[\"']\(.*\)[\"']}$s\$|\1$fs\2$fs\3|p" \
- -e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p" | \
- awk -F"$fs" '{
- indent = length($1)/2;
- vname[indent] = $2;
- for (i in vname) {if (i > indent) {delete vname[i]; idx[i]=0}}
- if (length($2) == 0) {vname[indent] = ++idx[indent] };
- if (length($3) > 0) {
- vn=""; for (i=0; i<indent; i++) {vn = (vn)(vname[i])("_")}
- if ("'"$2"'_" == vn) {
- print substr($3 ,1 , match($3,":")-1)
- }
- }
- }'
- }
- # Check if volume files exist to avoid creating an empty folder
- VOLUME_LIST=$(parseYaml compose.dev.yaml services_app_volumes)
- IGNORE_LIST="./src/app/code ./src/m2-hotfixes ./src/patches ./src/var/log ./src/var/report ./src"
- IS_VALID=true
- # Loop through all files missing from the compose.dev.yaml file
- for file in $VOLUME_LIST; do
- if [[ ! -e $file && " $IGNORE_LIST " != *" $file "* ]]; then
- echo "$file: No such file or directory"
- IS_VALID=false
- fi
- done
- # Wait to exit until all missing files have been outputted to the user
- [ $IS_VALID = false ] && echo "Failed to start docker for missing volume files" && exit
- bin/docker-compose up -d --remove-orphans "$@"
- ## Blackfire support
- ## ------------------
- ## First register the blackfire agent with:
- #bin/root blackfire-agent --register --server-id={YOUR_SERVER_ID} --server-token={YOUR_SERVER_TOKEN}
- ## Then uncomment the below line (and leave uncommented) to start the agent automatically with bin/start:
- #bin/root /etc/init.d/blackfire-agent start
- # Check if cron was previously enabled and restart it if needed
- if bin/cli test -f /var/www/html/var/.cron-enabled; then
- echo "Cron was previously enabled, restarting cron service..."
- bin/cron start
- fi
- bin/cache-clean --watch
|