docker-icingaweb2/build.bash
Julian Brost af683bee76 Introduce explicit build mode and clean up code
This commit introduces an explicit build mode in get-mods.sh that determines
how the versions of external modules are selected.

Possible modes are:
 - release: chooses latest release for each module
 - snapshot: uses a snapshot/development version for each module (if available)

In action.bash, the mode is automatically set based on the GITHUB_REF variable.
For tags starting with "v" (i.e. version tags like v2.9.0) it is release, other
tag names are not supported. For branches it is snapshot.
2022-04-01 14:22:59 +02:00

39 lines
855 B
Bash
Executable File

#!/bin/bash
# Icinga Web 2 Docker image | (c) 2020 Icinga GmbH | GPLv2+
set -exo pipefail
IW2SRC="$1"
export BUILD_MODE="${2:-release}"
if [ -z "$IW2SRC" ]; then
cat <<EOF >&2
Usage: ${0} /icingaweb2/source/dir
EOF
false
fi
IW2SRC="$(realpath "$IW2SRC")"
BLDCTX="$(realpath "$(dirname "$0")")"
docker build -f "${BLDCTX}/action.Dockerfile" -t icinga/icingaweb2-builder "$BLDCTX"
docker run --rm -i \
-v "${IW2SRC}:/iw2src:ro" \
-v "${BLDCTX}:/bldctx:ro" \
-v /var/run/docker.sock:/var/run/docker.sock \
-e BUILD_MODE \
icinga/icingaweb2-builder bash <<EOF
set -exo pipefail
git -C /iw2src archive --prefix=iw2cp/icingaweb2/ HEAD |tar -xC /
cd /iw2cp
/bldctx/get-mods.sh "$BUILD_MODE"
/bldctx/composer.bash
patch -d icingaweb2 -p0 < /bldctx/icingaweb2.patch
cp -r /entrypoint .
docker build -f /bldctx/Dockerfile -t icinga/icingaweb2 .
EOF