#!/bin/bash set -euo pipefail function die() { echo "$1" exit 1 } function build_image() { local dockerfile="$1" local image_name="${dockerfile//Dockerfile./}" docker build -t "$image_name:latest" -f "$dockerfile" . || die "Failed to build $image_name" } pids=() for dockerfile in Dockerfile.*; do ( build_image "$dockerfile" ) & pids+=($!) done fail=0 for pid in "${pids[@]}"; do wait "$pid" || fail=1 done if (( fail )); then echo "One or more builds failed." exit 1 fi