docker-icinga2/build.bash
Alexander Aleksandrovič Klimov 62ccdab6af
build.bash: workaround a bug in docker buildx build CLI
--build-context dirs seem to have to end with a / to be accepted.
2024-01-26 12:02:16 +01:00

42 lines
864 B
Bash
Executable File

#!/bin/bash
# Icinga 2 Docker image | (c) 2020 Icinga GmbH | GPLv2+
set -exo pipefail
I2SRC="$1"
ACTION="${2:-local}"
TAG="${3:-test}"
if [ -z "$I2SRC" ]; then
cat <<EOF >&2
Usage: ${0} /icinga2/source/dir [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/icinga2:$TAG" --build-context "icinga2-git=$(realpath "$I2SRC")/.git/" "$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