瀏覽代碼

Improve bin/docker-compose

Ranger Chan 2 年之前
父節點
當前提交
866a0547f1
共有 5 個文件被更改,包括 12 次插入7 次删除
  1. 2 2
      README.md
  2. 3 3
      compose/bin/docker-compose
  3. 1 1
      compose/bin/download
  4. 1 1
      compose/bin/setup
  5. 5 0
      compose/bin/start

+ 2 - 2
README.md

@@ -161,7 +161,7 @@ curl -s https://raw.githubusercontent.com/markshust/docker-magento/master/lib/te
 bin/download 2.4.5-p1
 
 # or for Magento core development:
-# bin/docker-compose --no-dev up -d
+# bin/start --no-dev
 # bin/setup-composer-auth
 # bin/cli git clone git@github.com:magento/magento2.git .
 # bin/cli git checkout 2.4-develop
@@ -191,7 +191,7 @@ cp -R ~/Sites/existing src
 # or: git clone git@github.com:myrepo.git src
 
 # Start some containers, copy files to them and then restart the containers:
-bin/docker-compose --no-dev up -d
+bin/start --no-dev
 bin/copytocontainer --all ## Initial copy will take a few minutes...
 
 # Import existing database:

+ 3 - 3
compose/bin/docker-compose

@@ -1,9 +1,9 @@
 #!/bin/bash
 
-if hash docker-compose 2>/dev/null; then
-  DOCKER_COMPOSE="docker-compose"
-else
+if docker compose version > /dev/null 2>&1; then
   DOCKER_COMPOSE="docker compose"
+else
+  DOCKER_COMPOSE="docker-compose"
 fi
 
 if [ "$1" == "--no-dev" ]; then

+ 1 - 1
compose/bin/download

@@ -14,7 +14,7 @@ else
   sed -i -e 's/7.4\-fpm\-15/8.1\-fpm\-1/g' docker-compose.yml
 fi
 
-bin/docker-compose --no-dev up -d
+bin/start --no-dev
 [ $? != 0 ] && echo "Failed to start Docker services" && exit
 
 bin/setup-composer-auth

+ 1 - 1
compose/bin/setup

@@ -18,7 +18,7 @@ DOMAIN=${1:-magento.test}
 
 bin/stop
 
-bin/docker-compose --no-dev up -d
+bin/start --no-dev
 [ $? != 0 ] && echo "Failed to start Docker services" && exit
 
 bin/clinotty chmod u+x bin/magento

+ 5 - 0
compose/bin/start

@@ -5,6 +5,11 @@ 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 "$@"
+  exit $?
+fi
+
 # Ref: https://stackoverflow.com/a/51789677/9821321
 function parseYaml {
   local s