-
Notifications
You must be signed in to change notification settings - Fork 164
/
build-images.sh
executable file
·87 lines (73 loc) · 1.77 KB
/
build-images.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#! /bin/bash
set -eu
usage()
{
cat << EOF
Builds Gadgetron runtime and dev images
Usage: $0 [options]
Options:
--type <type> Type of image to build: 'dev' (development) or 'rt' (runtime) or 'all' (default)
--flavor <flavor> Flavor: 'cuda' or 'nocuda' or 'all' (default)
--base-name <name> Base name for images, <base-name>_<type>_<flavor>:<tag>, default 'ghcr.io/gadgetron/gadgetron/gadgetron_ubuntu'
--tag <tag> Tag for images, default 'latest'
--push Push images
-h, --help Brings up this menu
EOF
}
export DOCKER_BUILDKIT=1
types=()
types_default=("dev" "rt")
flavors=()
flavors_default=("cuda" "nocuda")
image_tag="latest"
base_name="ghcr.io/gadgetron/gadgetron/ubuntu22.04"
while [[ $# -gt 0 ]]; do
key="$1"
case $key in
--flavor)
flavors+=("$2")
shift 2
;;
--type)
types+=("$2")
shift 2
;;
--tag)
image_tag="$2"
shift 2
;;
--base-name)
base_name="$2"
shift 2
;;
--push)
push=1
shift 1
;;
-h|--help)
usage
exit
;;
*)
echo "ERROR: unknown option \"$key\""
usage
exit 1
;;
esac
done
if [ ${#types[@]} -eq 0 ]; then
types=("${types_default[@]}")
fi
if [ ${#flavors[@]} -eq 0 ]; then
flavors=("${flavors_default[@]}")
fi
for t in "${types[@]}"; do
for f in "${flavors[@]}"; do
image_name="${base_name}_${t}_${f}:${image_tag}"
build_stage="gadgetron_${t}_${f}"
docker build --build-arg BUILDKIT_INLINE_CACHE=1 --target "$build_stage" -t "$image_name" -f "$(dirname "$0")/Dockerfile" "$(dirname "$0")"
if [[ -n "${push:-}" ]]; then
docker push "$image_name"
fi
done
done