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}/}
if [ "${rel_dir}" = "${df_dir}" ]; then rel_dir=""; fi
suffix=""
if [ -n "${rel_dir}" ]; then
suffix="-$(echo "${rel_dir}" | tr '/' '-')"
fi
image_name_variant="${image_name}${suffix}"
full_ref_variant="${REGISTRY}/${NAMESPACE}/${image_name_variant}:${DOCKER_TAG}"
log_file="${LOG_DIR}/${image_name_variant}.log"
echo "[docker] build ${full_ref_variant} depuis ${df_dir} (branche ${branch}) | log: ${log_file}"
{ {
echo "== BUILD ${full_ref} ==" echo "== BUILD ${full_ref_variant} =="
echo "context=${df_dir} dockerfile=${df}"
date -Is date -Is
docker buildx build \ docker buildx build \
--pull \ --pull \
--ssh default \ --ssh default \
--progress=plain \ --progress=plain \
--tag "${full_ref}" \ --file "${df}" \
"${path}" --tag "${full_ref_variant}" \
"${df_dir}"
} 2>&1 | tee -a "${log_file}" } 2>&1 | tee -a "${log_file}"
echo "[docker] push ${full_ref} | log: ${log_file}" echo "[docker] push ${full_ref_variant} | log: ${log_file}"
{ {
echo "== PUSH ${full_ref} ==" echo "== PUSH ${full_ref_variant} =="
date -Is date -Is
docker push "${full_ref}" docker push "${full_ref_variant}"
} 2>&1 | tee -a "${log_file}" } 2>&1 | tee -a "${log_file}"
echo "${full_ref} ${log_file}" >> "${SUMMARY_FILE}" echo "${full_ref_variant} ${log_file}" >> "${SUMMARY_FILE}"
done
done done
echo "[docker] terminé" echo "[docker] terminé"