mirror of
https://github.com/jessfraz/dockerfiles.git
synced 2025-04-11 22:52:46 +02:00
parallel
Signed-off-by: Jess Frazelle <acidburn@google.com>
This commit is contained in:
parent
70dd5abcd8
commit
6b5e3e4b8a
42
build-all.sh
42
build-all.sh
@ -3,6 +3,8 @@ set -e
|
|||||||
set -o pipefail
|
set -o pipefail
|
||||||
|
|
||||||
REPO_URL="${REPO_URL:-r.j3ss.co}"
|
REPO_URL="${REPO_URL:-r.j3ss.co}"
|
||||||
|
JOBS=${JOBS:-2}
|
||||||
|
export REPO_URL
|
||||||
|
|
||||||
build_and_push(){
|
build_and_push(){
|
||||||
base=$1
|
base=$1
|
||||||
@ -33,16 +35,10 @@ build_and_push(){
|
|||||||
docker push --disable-content-trust=false ${REPO_URL}/${base}:latest
|
docker push --disable-content-trust=false ${REPO_URL}/${base}:latest
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
export -f build_and_push
|
||||||
|
|
||||||
main(){
|
dofile() {
|
||||||
# get the dockerfiles
|
f=$1
|
||||||
IFS=$'\n'
|
|
||||||
files=( $(find . -iname '*Dockerfile' | sed 's|./||' | sort) )
|
|
||||||
unset IFS
|
|
||||||
|
|
||||||
ERRORS=()
|
|
||||||
# build all dockerfiles
|
|
||||||
for f in "${files[@]}"; do
|
|
||||||
image=${f%Dockerfile}
|
image=${f%Dockerfile}
|
||||||
base=${image%%\/*}
|
base=${image%%\/*}
|
||||||
build_dir=$(dirname $f)
|
build_dir=$(dirname $f)
|
||||||
@ -56,19 +52,31 @@ main(){
|
|||||||
build_and_push "${base}" "${suite}" "${build_dir}"
|
build_and_push "${base}" "${suite}" "${build_dir}"
|
||||||
} || {
|
} || {
|
||||||
# add to errors
|
# add to errors
|
||||||
ERRORS+=("${base}:${suite}")
|
export ERRORS="${ERRORS} ${base}:${suite} "
|
||||||
}
|
}
|
||||||
echo
|
echo
|
||||||
echo
|
echo
|
||||||
done
|
}
|
||||||
|
export -f dofile
|
||||||
|
|
||||||
if [ ${#ERRORS[@]} -eq 0 ]; then
|
main(){
|
||||||
|
# get the dockerfiles
|
||||||
|
IFS=$'\n'
|
||||||
|
files=( $(find . -iname '*Dockerfile' | sed 's|./||' | sort) )
|
||||||
|
unset IFS
|
||||||
|
|
||||||
|
export ERRORS=""
|
||||||
|
# build all dockerfiles
|
||||||
|
echo "Running in parallel with ${JOBS} jobs."
|
||||||
|
parallel -j"${JOBS}" dofile "{1}" ::: "${files[@]}"
|
||||||
|
|
||||||
|
if [[ "$ERRORS" == "" ]]; then
|
||||||
echo "No errors, hooray!"
|
echo "No errors, hooray!"
|
||||||
else
|
else
|
||||||
echo "[ERROR] Some images did not build correctly, see below." >&2
|
echo "[ERROR] Some images did not build correctly, see below." >&2
|
||||||
echo "These images failed: ${ERRORS[@]}" >&2
|
echo "These images failed: ${ERRORS[@]}" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
main $@
|
main $@
|
||||||
|
Loading…
x
Reference in New Issue
Block a user