File: create_docker_images_and_containers

package info (click to toggle)
cpputest 4.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,688 kB
  • sloc: cpp: 31,212; sh: 4,978; ansic: 1,360; makefile: 775; ruby: 676; xml: 8; sed: 1
file content (37 lines) | stat: -rwxr-xr-x 1,222 bytes parent folder | download | duplicates (2)
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"