From 38b8ed5c0a34cf08adff16ecf30e13d15368b8e2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C3=ABl=20Minelli?= <git@minelli.swiss>
Date: Fri, 11 Oct 2024 23:47:36 +0200
Subject: [PATCH] Infra => Update script to add CPU env var and env var file
 copy

---
 infra | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/infra b/infra
index 55af933..56ae464 100755
--- a/infra
+++ b/infra
@@ -23,13 +23,17 @@ if [ $? -ne 0 ]; then
     DOCKER_COMPOSE_COMMAND="docker-compose"
 fi
 
-${DOCKER_COMPOSE_COMMAND} kill
+CPU_LIMIT=$(($(nproc)-1))
+CPU_LIMIT=$(($CPU_LIMIT <= 0 ? 1 : $CPU_LIMIT))
+
+CPU_LIMIT=${CPU_LIMIT} ${DOCKER_COMPOSE_COMMAND} kill
 
 # If argument is --run, run the docker compose file
 if [ "$1" = "--run" ]; then
     # Check if .env file exists
     if [ -f $ENV_FILE ]; then
-        ${DOCKER_COMPOSE_COMMAND} --env-file ${ENV_FILE} up --build -d
+        cp -f $ENV_FILE API/$ENV_FILE
+        CPU_LIMIT=${CPU_LIMIT} ${DOCKER_COMPOSE_COMMAND} --env-file ${ENV_FILE} up --build -d
     else
         echo "Need a file named ${ENV_FILE} providing environment variables."
         exit 2
-- 
GitLab