summaryrefslogtreecommitdiffstats
path: root/ci
diff options
context:
space:
mode:
Diffstat (limited to 'ci')
-rwxr-xr-xci/build_rpm/build_rpms.sh25
1 files changed, 24 insertions, 1 deletions
diff --git a/ci/build_rpm/build_rpms.sh b/ci/build_rpm/build_rpms.sh
index c98747b6..811eb13a 100755
--- a/ci/build_rpm/build_rpms.sh
+++ b/ci/build_rpm/build_rpms.sh
@@ -25,11 +25,34 @@ function build_rpm_pkg {
$OPNFV_ARTIFACT_VERSION
}
+function cleanup_container {
+ echo "Cleaning daisy container"
+ containers_to_kill=$(sudo docker ps --filter "name=daisy" \
+ --format "{{.Names}}" -a)
+
+ if [[ ! -z "$containers_to_kill" ]]; then
+ volumes_to_remove=$(sudo docker inspect -f \
+ '{{range .Mounts}} {{printf "%s\n" .Name }}{{end}}' \
+ ${containers_to_kill} | egrep -v '(^\s*$)' | sort | uniq)
+
+ echo "Stopping containers... $containers_to_kill"
+ (sudo docker stop -t 2 ${containers_to_kill} 2>&1) > /dev/null
+ echo "Removing containers... $containers_to_kill"
+ (sudo docker rm -v -f ${containers_to_kill} 2>&1) > /dev/null
+
+ if [[ ! -z "$containers_to_kill" ]]; then
+ echo "Removing volumes... $volumes_to_remove"
+ (sudo docker volume rm ${volumes_to_remove} 2>&1) || true > /dev/null
+ fi
+ fi
+}
+
function cleanup_docker_image {
if [ ! -z "$(sudo docker images -q opnfv/daisy)" ]; then
- sudo docker rmi opnfv/daisy >/dev/null 2>&1
+ sudo docker rmi -f opnfv/daisy
fi
}
+cleanup_container
cleanup_docker_image
build_rpm_pkg