From 6692316ed73d9e0ac61f68add655a51c51f73eef Mon Sep 17 00:00:00 2001 From: Etienne Pallier Date: Mon, 16 Oct 2023 12:56:21 +0200 Subject: [PATCH] BUILD auto in PYROS_DOCKER_UPDATE if any docker file changed --- docker/PYROS_DOCKER_UPDATE | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/docker/PYROS_DOCKER_UPDATE b/docker/PYROS_DOCKER_UPDATE index 4f82862..bdb4b57 100755 --- a/docker/PYROS_DOCKER_UPDATE +++ b/docker/PYROS_DOCKER_UPDATE @@ -1,10 +1,10 @@ #!/usr/bin/env bash # In docker/ folder -#root_folder=$(pwd 2>&1) +root_folder=$(pwd 2>&1) already_uptodate="Déjà à jour." -check_files=("docker-compose.yml" "Dockerfile" "install/requirements.in") +check_files=("docker-compose.yml" "Dockerfile" "install/requirements.in" "install/requirements.txt" "doc_rst/requirements.in" "doc_rst/requirements.txt") check_files="${check_files[@]}" function git_pull { dir=$1 @@ -12,19 +12,30 @@ function git_pull { cd $dir gitpull_output=$(git pull 2>&1) # IF git pull error (other than $already_uptodate) => stop - if [[ $? -eq 1 && "$gitpull_output"!="$already_uptodate" ]]; then + if [[ $? -eq 1 && "$gitpull_output" != "$already_uptodate" ]]; then echo "Git pull failed. Error message is:" echo $gitpull_output exit 1 fi echo $gitpull_output + # test only + #gitpull_output=$gitpull_output."Dockerfile " + #gitpull_output=$gitpull_output."doc_rst/requirements.txt " # Check if exists file changed that requires rebuild #for file in "${check_files[@]}" for f in $check_files ; do #echo "check $f" - if grep -q "$f" <<< "$gitpull_output"; then - echo "WARNING : One of docker related files has been changed. You should build again the PyROS Image" - return 1 + #if [ $f == "doc_rst/requirements.txt" ] ; then + if grep -q "$f" <<< "$gitpull_output" ; then + echo "WARNING : One of docker related files ($f) has been changed. You should build again the PyROS Image before going on with the UPDATE..." + echo "=> Build & start again the PyROS image ? ([y]/n)" + read input ; [ -z ${input} ] && input="y" + #echo $answer + [ $input != "y" ] && exit 1 + #echo $root_folder + (cd $root_folder && ./PYROS_DOCKER_BUILD && ./PYROS_DOCKER_START) + # BUILF only once !!! + break fi done cd - > /dev/null -- libgit2 0.21.2