forked from mobtitude/docker-php-xdebug
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild-all.sh
More file actions
executable file
·64 lines (52 loc) · 1.52 KB
/
build-all.sh
File metadata and controls
executable file
·64 lines (52 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env bash
#
# Script builds all Dockerfiles defined in build directory
# Prints summary after all images have been built (successfully or not)
#
image_name="$1"
# Checks if image name was provided by user
if [ -z "${image_name}" ]; then
echo "Usage: $0 [docker_image_name]" >&2
exit -1
fi
# Change current path to project root
script_path=$(dirname "$0")
cd "${script_path}/../" || exit -1
# Text formatting
text_bold=$(tput bold)
text_red=$(tput setaf 1)
text_normal=$(tput sgr0)
# Summary arrays
build_failed=()
build_done=()
# Loop through all available directories in ./build
for i in ./build/*/; do
version=$(basename "$i");
image="${image_name}:${version}"
echo "${text_bold}* Building ${image} ${text_normal}"
# Builds image and check for return code
if docker buildx build --push --platform linux/arm64,linux/amd64 -t "${image}" "./build/${version}"; then
build_done+=( "${image}" )
else
echo "${text_bold}${text_red}* ERROR when building ${image} ${text_normal}"
build_failed+=( "${image}" )
fi
done
# Prints summary for successful builds
if [ "${#build_done[@]}" -gt 0 ]; then
echo "${text_bold}"
echo "Docker has successfully built the following images:${text_normal}"
for img in "${build_done[@]}"; do
echo "* ${img}"
done
echo -n "${text_normal}"
fi
# Prints summary for failed builds
if [ "${#build_failed[@]}" -gt 0 ]; then
echo "${text_red}"
echo "Docker failed when building the following images:"
for img in "${build_failed[@]}"; do
echo "${text_red}* ${img}${text_normal}"
done
exit 1
fi