Ensure a rebuild of a container is a verbose event.

This commit is contained in:
Stephane Gourichon
2024-03-27 23:31:16 +01:00
parent 405c1d5acc
commit 3044d9c2ec
2 changed files with 44 additions and 10 deletions

View File

@@ -46,6 +46,9 @@ do
PATH_OF_CONTAINER="$( docker inspect --format='{{ index .Config.Labels "com.docker.compose.project.working_dir" }}' $CONTAINER_ID )" PATH_OF_CONTAINER="$( docker inspect --format='{{ index .Config.Labels "com.docker.compose.project.working_dir" }}' $CONTAINER_ID )"
NAME_OF_CONTAINER="$( docker inspect --format='{{ .Name }}' $CONTAINER_ID )" NAME_OF_CONTAINER="$( docker inspect --format='{{ .Name }}' $CONTAINER_ID )"
echo "IMPORTANT: updating container $NAME_OF_CONTAINER from $PATH_OF_CONTAINER"
cd $PATH_OF_CONTAINER cd $PATH_OF_CONTAINER
docker-compose pull || { fail_one "pull" ; continue ; } docker-compose pull || { fail_one "pull" ; continue ; }
docker-compose build --no-cache || { fail_one "build" ; continue ; } docker-compose build --no-cache || { fail_one "build" ; continue ; }

View File

@@ -1,22 +1,53 @@
#!/bin/bash #!/bin/bash
set -eu
LOGFILENAME=$(mktemp /tmp/run_and_output_only_on_error_XXXXXX) LOGFILENAME=$(mktemp /tmp/run_and_output_only_on_error_XXXXXX)
# set -xv
trap "rm -f ${LOGFILENAME}" EXIT trap "rm -f ${LOGFILENAME}" EXIT
if REASONS_FOR_OUTPUT=()
(
$@ (
) > "${LOGFILENAME}" 2>&1 set -xv
$@
) > "${LOGFILENAME}" 2>&1
RC=$?
if [[ "$RC" != 0 ]]
then then
true REASONS_FOR_OUTPUT+=( "Return code $RC" )
else fi
if grep -qiw WARNING "${LOGFILENAME}"
then
REASONS_FOR_OUTPUT+=("WARNING appears in output")
fi
if grep -qiw ERROR "${LOGFILENAME}"
then
REASONS_FOR_OUTPUT+=("ERROR appears in output")
fi
if grep -qiw FAILURE "${LOGFILENAME}"
then
REASONS_FOR_OUTPUT+=("FAILURE appears in output")
fi
if grep -qiw IMPORTANT "${LOGFILENAME}"
then
REASONS_FOR_OUTPUT+=("IMPORTANT appears in output")
fi
if [[ ${#REASONS_FOR_OUTPUT[@]} != 0 ]]
then
echo "Verbose report on running: $@"
echo
echo "${#REASONS_FOR_OUTPUT[@]} reason(s) for verbose output: "
printf '* %s\n' "${REASONS_FOR_OUTPUT[@]}"
echo echo
echo "Error on running: $@"
echo echo
echo "Here's the program's output (out and err combined)" echo "Here's the program's output (out and err combined)"
echo ========================================================================
cat "${LOGFILENAME}" cat "${LOGFILENAME}"
echo ========================================================================
fi fi