prophunt-garrysmod/test/testBuild.sh
Lucas Briese 2d702db907 moved to multi multi stage build
docker ci executing hook with always pull before build. Therefore e.g. first image is created but right after overwritten by previous image.
2021-11-08 19:46:28 +01:00

45 lines
1.1 KiB
Bash

#!/bin/bash
readonly SUFFIX="$1"
readonly BUILD_TTT="$(grep -qF -e '--skip-ttt' <<< "$@" && echo false || echo true)"
readonly PUSH="$(grep -qF -e '--push' <<< "$@" && echo true || echo false)"
readonly repository="${DOCKER_REPO:-jusito/docker-ttt}"
if [ "${DEBUGGING}" = "true" ]; then
set -o xtrace
else
DEBUGGING="false"
fi
set -o errexit
set -o nounset
set -o pipefail
function process() {
tag_prefix="$1"
subdir="$2"
cache_option="$(grep -qF -e '--no-cache' <<< "$@" && echo "--no-cache" || echo "")"
docker rmi "$repository:$tag_prefix${SUFFIX}" || true
docker build --target "$subdir" $cache_option -t "$repository:$tag_prefix${SUFFIX}" "$subdir/"
if "$PUSH"; then
docker push "$repository:$tag_prefix${SUFFIX}"
fi
}
echo "[testBuild][INFO] build"
process "lgsm_debian" "lgsm" --no-cache
process "gmod_debian" "gmod"
if "$BUILD_TTT"; then
process "gmod_ttt_debian" "TTT"
fi
docker rmi "$repository:latest${SUFFIX}" || true
docker tag "$repository:gmod_ttt_debian${SUFFIX}" "$repository:latest${SUFFIX}"
if "$PUSH"; then
docker push "$repository:latest${SUFFIX}"
fi
echo "[testBuild][INFO] build done!"