forked from pschmitt/docker-zabbix-agent2-custom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·53 lines (42 loc) · 1.06 KB
/
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
#!/usr/bin/env bash
IMAGE_NAME="pschmitt/zabbix-agent2"
usage() {
echo "Usage: $0"
}
array_join() {
local IFS="$1"
shift
echo "$*"
}
get_available_architectures() {
local image="$1"
local tag="${2:-latest}"
docker buildx imagetools inspect --raw "${image}:${tag}" | \
jq -r '.manifests[].platform | .os + "/" + .architecture + "/" + .variant' | \
sed 's#/$##' | sort
}
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]
then
set -ex
cd "$(readlink -f "$(dirname "$0")")" || exit 9
# shellcheck disable=2207
platforms=($(get_available_architectures zabbixmultiarch/zabbix-agent2 latest))
PUSH_IMAGE=true
BUILD_TYPE=manual
if [[ "$TRAVIS" == "true" ]]
then
BUILD_TYPE=travis
elif [[ "$GITHUB_ACTIONS" == "true" ]]
then
BUILD_TYPE=github
fi
docker buildx build \
--platform "$(array_join "," "${platforms[@]}")" \
--output "type=image,push=${PUSH_IMAGE}" \
--no-cache \
--label=built-by=pschmitt \
--label=build-type="$BUILD_TYPE" \
--label=built-on="$HOSTNAME" \
--tag "${IMAGE_NAME}:latest" \
.
fi