ci(build): discover nested Dockerfiles in submodules; log and summarize all builds
Some checks are pending
dev / build-and-push (push) Waiting to run

This commit is contained in:
Nicolas Cantu 2025-09-10 13:11:34 +02:00
parent 244852bad5
commit ca7256a60d

View File

@ -52,32 +52,48 @@ for name in "${submodules[@]}"; do
continue continue
fi fi
if [ ! -f "${path}/Dockerfile" ]; then mapfile -t dockerfiles < <(find "${path}" -type f -name Dockerfile | sort)
if [ ${#dockerfiles[@]} -eq 0 ]; then
echo "[docker] aucun Dockerfile dans ${path}, ignoré" echo "[docker] aucun Dockerfile dans ${path}, ignoré"
echo "skip $(basename \"${path}\")" >> "${SUMMARY_FILE}"
continue continue
fi fi
log_file="${LOG_DIR}/$(basename "${path}").log" for df in "${dockerfiles[@]}"; do
echo "[docker] build ${full_ref} depuis ${path} (branche ${branch}) | log: ${log_file}" df_dir=$(dirname "${df}")
{ rel_dir=${df_dir#${path}/}
echo "== BUILD ${full_ref} ==" if [ "${rel_dir}" = "${df_dir}" ]; then rel_dir=""; fi
date -Is suffix=""
docker buildx build \ if [ -n "${rel_dir}" ]; then
--pull \ suffix="-$(echo "${rel_dir}" | tr '/' '-')"
--ssh default \ fi
--progress=plain \ image_name_variant="${image_name}${suffix}"
--tag "${full_ref}" \ full_ref_variant="${REGISTRY}/${NAMESPACE}/${image_name_variant}:${DOCKER_TAG}"
"${path}"
} 2>&1 | tee -a "${log_file}"
echo "[docker] push ${full_ref} | log: ${log_file}" log_file="${LOG_DIR}/${image_name_variant}.log"
{ echo "[docker] build ${full_ref_variant} depuis ${df_dir} (branche ${branch}) | log: ${log_file}"
echo "== PUSH ${full_ref} ==" {
date -Is echo "== BUILD ${full_ref_variant} =="
docker push "${full_ref}" echo "context=${df_dir} dockerfile=${df}"
} 2>&1 | tee -a "${log_file}" date -Is
docker buildx build \
--pull \
--ssh default \
--progress=plain \
--file "${df}" \
--tag "${full_ref_variant}" \
"${df_dir}"
} 2>&1 | tee -a "${log_file}"
echo "${full_ref} ${log_file}" >> "${SUMMARY_FILE}" echo "[docker] push ${full_ref_variant} | log: ${log_file}"
{
echo "== PUSH ${full_ref_variant} =="
date -Is
docker push "${full_ref_variant}"
} 2>&1 | tee -a "${log_file}"
echo "${full_ref_variant} ${log_file}" >> "${SUMMARY_FILE}"
done
done done
echo "[docker] terminé" echo "[docker] terminé"