Przeglądaj źródła

Simplify RAM check

Use `docker info -f` to get the number of bytes. This results in fewer
dependencies on external programs, and better usage of Bash shell math.

Removes comment stemming from confusion about GiB vs GB.
Dan Church 2 lat temu
rodzic
commit
3c5bf1f6e6
1 zmienionych plików z 6 dodań i 3 usunięć
  1. 6 3
      compose/bin/setup

+ 6 - 3
compose/bin/setup

@@ -1,9 +1,12 @@
 #!/bin/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
+MEM_BYTES=$(docker info -f '{{.MemTotal}}')
+MEM_MB=$(( MEM_BYTES / 1000000 ))
+(( MEM_MB >= 6000 )) || {
+  echo 'There must be at least 6GB of RAM allocated to Docker to continue.' >&2
+  exit 1
+}
 
 # shellcheck source=../env/db.env
 source env/db.env