| 1 | #!/bin/bash |
| 2 | #$1 is the container name |
| 3 | |
| 4 | checkForCppUTestToolsEnvVariable() { |
| 5 | if [ -z "$CPPUTEST_HOME" ] ; then |
| 6 | echo "CPPUTEST_HOME not set. You must set CPPUTEST_HOME to the top level CppUTest directory" |
| 7 | exit 1 |
| 8 | fi |
| 9 | if [ ! -d "$CPPUTEST_HOME" ] ; then |
| 10 | echo "CPPUTEST_HOME not set to a directory. You must set CPPUTEST_HOME to the top level CppUTest directory" |
| 11 | exit 2 |
| 12 | fi |
| 13 | } |
| 14 | |
| 15 | checkForImageNameParameter() { |
| 16 | if [ -z "$container" ] ; then |
| 17 | echo "Container name parameter not set. Check the docker directory. It should be the extension of the Dockerfile. e.g. ubuntu" |
| 18 | exit 1 |
| 19 | fi |
| 20 | if [ ! -f "$CPPUTEST_HOME/docker/Dockerfile.$container" ] ; then |
| 21 | echo "The Dockerfile docker/Dockerfile.$container doesn't exist. Typo?" |
| 22 | exit 2 |
| 23 | fi |
| 24 | } |
| 25 | |
| 26 | |
| 27 | container=$1 |
| 28 | checkForCppUTestToolsEnvVariable |
| 29 | checkForImageNameParameter |
| 30 | |
| 31 | docker build -f $CPPUTEST_HOME/docker/Dockerfile.$container --tag cpputest/$container:latest . |
| 32 | docker container rm cpputest_$container |
| 33 | docker create -it -v$CPPUTEST_HOME:/cpputest -e "CPPUTEST_HOME=/cpputest" --name cpputest_$container cpputest/$container:latest |
| 34 | |
| 35 | echo "You can run your container through: docker start -i cpputest_<container>. E.g. docker start -i cpputest_$container" |
| 36 | |
| 37 |