2018-12-24 14:12:59 +01:00
|
|
|
#! /bin/bash
|
|
|
|
# This file builds a docker image for testing the targeted debian version
|
2019-01-24 11:11:08 +01:00
|
|
|
# run-shellcheck
|
2018-12-24 14:12:59 +01:00
|
|
|
set -e
|
|
|
|
|
|
|
|
target=""
|
|
|
|
regex="debian[[:digit:]]+"
|
|
|
|
|
|
|
|
if [ $# -gt 0 ]; then
|
|
|
|
if [[ $1 =~ $regex ]]; then
|
|
|
|
target=$1
|
|
|
|
shift
|
|
|
|
fi
|
|
|
|
fi
|
2020-12-04 14:08:01 +01:00
|
|
|
if [ -z "$target" ]; then
|
2018-12-24 14:12:59 +01:00
|
|
|
echo "Usage: $0 <TARGET> [test_script...]" >&2
|
|
|
|
echo -n "Supported targets are: " >&2
|
|
|
|
#ls -1v "$(dirname "$0")"/docker/Dockerfile.* | sed -re 's=^.+/Dockerfile\.==' | tr "\n" " " >&2
|
|
|
|
find "$(dirname "$0")"/docker -name "*Dockerfile.*" | sort -V | sed -re 's=^.+/Dockerfile\.==' | tr "\n" " " >&2
|
|
|
|
echo >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
dockerfile="$(dirname "$0")"/docker/Dockerfile.${target}
|
2020-12-04 14:08:01 +01:00
|
|
|
if [ ! -f "$dockerfile" ]; then
|
|
|
|
echo "ERROR: No target available for $target" >&2
|
2018-12-24 14:12:59 +01:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
docker build -f "$dockerfile" -t "debian_cis_test:${target}" "$(dirname "$0")"/../
|
|
|
|
|
2019-01-23 12:54:33 +01:00
|
|
|
docker run --rm debian_cis_test:"${target}" "$@"
|