Update sapmachine
[mbt-docker.git] / build-image.sh
CommitLineData
d2913546
JB
1#!/usr/bin/env sh
2
0ab1c3ca
JB
3shopt -s extglob
4
28df4c45
JB
5images="mbt-node14-java8-docker mbt-node16-java8-docker mbt-node18-java8-docker \
6 mbt-node14-java11-docker mbt-node16-java11-docker mbt-node18-java11-docker \
81986a8d 7 mbt-node14-java17-docker mbt-node16-java17-docker mbt-node18-java17-docker \
f524c43a 8 mbt-node14-java20-docker mbt-node16-java20-docker mbt-node18-java20-docker"
d2913546 9
eb7c9a4e
JB
10# repositories="mbt-node14-java8-docker mbt-node16-java8-docker mbt-node18-java8-docker \
11# mbt-node14-java11-docker mbt-node16-java11-docker mbt-node18-java11-docker \
12# mbt-node14-java17-docker mbt-node16-java17-docker mbt-node18-java17-docker \
f524c43a 13# mbt-node14-java20-docker mbt-node16-java20-docker mbt-node18-java20-docker"
eb7c9a4e
JB
14
15repositories=${images}
3442a8df 16
d2913546 17usage() {
0ab1c3ca
JB
18 echo " Build docker images.
19
20 Usage:
21 ./$(basename $0) [-b <name>]
22 ./$(basename $0) [-p <name>]
23 ./$(basename $0) [-c]
24 ./$(basename $0) [-h]
25
26 Options:
27 -h Show this help.
28 -b <${images//+([[:space:]])/|}|all> Build docker images.
29 -p <${repositories//+([[:space:]])/|}|all> Push docker images.
30 -c Clean docker images." 1>&2; exit 1;
d2913546
JB
31}
32
3442a8df 33build_all() {
d2913546
JB
34 for image in ${images}; do
35 make NAME=${image}
36 done
37}
38
3442a8df
JB
39push_all() {
40 for repository in ${repositories}; do
41 make docker-push-registry NAME=${repository}
42 done
43}
44
d2913546 45[ $# -eq 0 ] && usage
3442a8df 46while getopts ":b:p:ch" option; do
d2913546 47 case "${option}" in
3442a8df 48 b)
d2913546 49 name=${OPTARG}
535de2bb 50 if [ ${name} = "all" ]; then
3442a8df 51 build_all
535de2bb 52 elif [ -z "${images##*$name*}" ]; then
d2913546
JB
53 make NAME=${name}
54 else
3442a8df 55 echo "Error: Unknown image name as option argument '${OPTARG}'" >&2;
d2913546 56 usage
d2913546
JB
57 fi
58 ;;
3442a8df
JB
59 p)
60 repository=${OPTARG}
535de2bb 61 if [ ${repository} = "all" ]; then
3442a8df 62 push_all
535de2bb 63 elif [ -z "${repositories##*$repository*}" ]; then
3442a8df
JB
64 make docker-push-registry NAME=${repository}
65 else
66 echo "Error: Unknown repository name as option argument '${OPTARG}'" >&2;
67 usage
68 fi
69 ;;
70 c)
71 make dist-clean
76f7abe4 72 ;;
30a42bd5 73 :)
3442a8df
JB
74 echo "Error: Missing option argument for '-${OPTARG}'" >&2;
75 usage
76 ;;
77 \?)
78 # Invalid option
79 echo "Error: Unknown or invalid option for '-${OPTARG}'" >&2;
30a42bd5 80 usage
76f7abe4 81 ;;
d2913546
JB
82 *|h)
83 usage
84 ;;
85 esac
86done