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