forked from containers/ramalama
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontainer_build.sh
executable file
·62 lines (51 loc) · 1.13 KB
/
container_build.sh
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
#!/bin/bash
available() {
command -v "$1" >/dev/null
}
select_container_manager() {
if available podman; then
conman_bin="podman"
return 0
elif available docker; then
conman_bin="docker"
return 0
fi
conman_bin="podman"
}
add_build_platform() {
conman_build+=("build" "--platform" "$platform")
conman_build+=("-t" "quay.io/ramalama/$image_name" ".")
}
build() {
cd "$1"
local image_name
image_name=$(echo "$1" | sed "s#/#:#g" | sed "s#container-images:##g")
local conman_build=("${conman[@]}")
if [ "$#" -lt 2 ]; then
add_build_platform
"${conman_build[@]}"
elif [ "$2" = "-d" ]; then
add_build_platform
echo "${conman_build[@]}"
elif [ "$2" = "push" ]; then
"${conman[@]}" push "quay.io/ramalama/$image_name"
else
add_build_platform
"${conman_build[@]}"
fi
cd - > /dev/null
}
main() {
set -eu -o pipefail
local conman_bin
select_container_manager
local conman=("$conman_bin")
local platform="linux/amd64"
if [ "$(uname -m)" = "aarch64" ]; then
platform="linux/arm64"
fi
for i in container-images/*/*; do
build "$i" "$@"
done
}
main "$@"