-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker.sh
executable file
·50 lines (43 loc) · 1.13 KB
/
docker.sh
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
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/bash
set -xe
source_dir=$PWD
container=ubuntu_builder_container
image=ubuntu_builder
function docker_create {
docker build -t $image .
set +e
docker container stop $container
docker container rm $container
set -e
docker run -dit -v $source_dir:$source_dir --name $container $image
}
function docker_build {
if ! docker inspect "$container" >/dev/null 2>&1; then
docker_create
fi
user=`id -u`:`id -g`
docker start $container
build_type=Debug
if [ "$1" != "" ] ; then
build_type=$1
fi
docker exec $container /bin/bash -c "cd $source_dir && $source_dir/build.sh $build_type"
}
function docker_test_run {
user=`id -u`:`id -g`
docker start $container
build_type=Debug
if [ "$1" != "" ] ; then
build_type=$1
fi
docker exec $container /bin/bash -c "cd '$source_dir/build_$build_type' && ctest"
}
function docker_test_coverage {
user=`id -u`:`id -g`
docker start $container
docker exec $container /bin/bash -c "cd $source_dir && $source_dir/coverage.sh"
}
function docker_bash {
docker exec -it $container /bin/bash
}
docker_$1 $2 $3