forked from nordic-institute/X-Road-Security-Server-sidecar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-build.sh
executable file
·68 lines (59 loc) · 1.97 KB
/
docker-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
62
63
64
65
66
67
68
#!/bin/bash
set -euo pipefail
no_cache=""
n=1
for i in "$@" ; do
if [[ $i == "--no-cache" ]] ; then
no_cache="--no-cache"
set -- "${@:1:n-1}" "${@:n+1}"
break
fi
((n++))
done
dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" >&/dev/null && pwd)"
version="${1:-7.0.0}"
tag="${2:-xroad-security-server-sidecar}"
repo="${3-}"
dist="${4-}"
repo_key="${5-}"
build() {
echo "BUILDING $tag:$version$2 using ${1#$dir/}"
local build_args=($no_cache --build-arg "VERSION=$version" --build-arg "TAG=$tag")
[[ -n $repo ]] && build_args+=(--build-arg "REPO=$repo")
[[ -n $repo_key ]] && build_args+=(--build-arg "REPO_KEY=$repo_key")
[[ -n $dist ]] && build_args+=(--build-arg "DIST=$dist")
[[ -n ${LABEL-} ]] && build_args+=(--label "$LABEL")
docker build -f "$1" "${build_args[@]}" -t "$tag:$version$2" "$dir"
}
build_variant() {
echo "BUILDING variant $tag:$version$1-$2"
docker build -f "$dir/Dockerfile-variant" \
--build-arg "VERSION=$version" \
--build-arg "FROM=$tag:$version$1" \
--build-arg "VARIANT=$2" \
-t "$tag:$version$1-$2" "$dir"
}
docker pull ubuntu:20.04 # Ensure latest ubuntu image is used as base
build "$dir/slim/Dockerfile" "-slim"
build_variant "-slim" "fi"
build_variant "-slim" "fo"
build_variant "-slim" "is"
build "$dir/Dockerfile" ""
build_variant "" "fi"
build_variant "" "ee"
build_variant "" "fo"
build_variant "" "is"
build "$dir/kubernetesBalancer/slim/primary/Dockerfile" "-slim-primary"
build "$dir/kubernetesBalancer/slim/secondary/Dockerfile" "-slim-secondary"
build "$dir/kubernetesBalancer/primary/Dockerfile" "-primary"
build "$dir/kubernetesBalancer/secondary/Dockerfile" "-secondary"
build_variant "-slim-primary" "fi"
build_variant "-slim-secondary" "fi"
build_variant "-slim-primary" "is"
build_variant "-slim-secondary" "is"
build_variant "-primary" "fi"
build_variant "-secondary" "fi"
build_variant "-primary" "is"
build_variant "-secondary" "is"
build_variant "-primary" "ee"
build_variant "-secondary" "ee"