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
|
#!/bin/bash
#$1 is the container name
checkForCppUTestToolsEnvVariable() {
if [ -z "$CPPUTEST_HOME" ] ; then
echo "CPPUTEST_HOME not set. You must set CPPUTEST_HOME to the top level CppUTest directory"
exit 1
fi
if [ ! -d "$CPPUTEST_HOME" ] ; then
echo "CPPUTEST_HOME not set to a directory. You must set CPPUTEST_HOME to the top level CppUTest directory"
exit 2
fi
}
checkForImageNameParameter() {
if [ -z "$container" ] ; then
echo "Container name parameter not set. Check the docker directory. It should be the extension of the Dockerfile. e.g. ubuntu"
exit 1
fi
if [ ! -f "$CPPUTEST_HOME/docker/Dockerfile.$container" ] ; then
echo "The Dockerfile docker/Dockerfile.$container doesn't exist. Typo?"
exit 2
fi
}
container=$1
checkForCppUTestToolsEnvVariable
checkForImageNameParameter
docker build -f $CPPUTEST_HOME/docker/Dockerfile.$container --tag cpputest/$container:latest .
docker container rm cpputest_$container
docker create -it -v$CPPUTEST_HOME:/cpputest -e "CPPUTEST_HOME=/cpputest" --name cpputest_$container cpputest/$container:latest
echo "You can run your container through: docker start -i cpputest_<container>. E.g. docker start -i cpputest_$container"
|