forked from Icinga/docker-icingaweb2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.bash
executable file
·42 lines (35 loc) · 969 Bytes
/
build.bash
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
#!/bin/bash
# Icinga Web 2 Docker image | (c) 2020 Icinga GmbH | GPLv2+
set -exo pipefail
IW2SRC="$1"
export BUILD_MODE="${2:-release}"
ACTION="${3:-local}"
TAG="${4:-test}"
if [ -z "$IW2SRC" ]; then
cat <<EOF >&2
Usage: ${0} /icingaweb2/source/dir [release|snapshot [local|all|push [TAG]]]
EOF
false
fi
if ! docker version; then
echo 'Docker not found' >&2
false
fi
if ! docker buildx version; then
echo '"docker buildx" not found (see https://docs.docker.com/buildx/working-with-buildx/ )' >&2
false
fi
OUR_DIR="$(realpath "$(dirname "$0")")"
COMMON_ARGS=(-t "icinga/icingaweb2:$TAG" --build-context "icingaweb2-git=$(realpath "$IW2SRC")/.git" --build-arg "BUILD_MODE=$BUILD_MODE" "$OUR_DIR")
BUILDX=(docker buildx build --platform "$(cat "${OUR_DIR}/platforms.txt")")
case "$ACTION" in
all)
"${BUILDX[@]}" "${COMMON_ARGS[@]}"
;;
push)
"${BUILDX[@]}" --push "${COMMON_ARGS[@]}"
;;
*)
docker buildx build --load "${COMMON_ARGS[@]}"
;;
esac