Skip to content

Commit

Permalink
Remove build docker volumes if OS_BUILD_ENV_CLEAN_VOLUMES is set.
Browse files Browse the repository at this point in the history
  • Loading branch information
ingvagabund committed Sep 1, 2017
1 parent 665899f commit 44102be
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion hack/lib/build/environment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,17 @@ readonly -f os::build::environment::release::workingdir
# (unless OS_BUILD_ENV_LEAVE_CONTAINER is set, in which case it will only stop the container).
function os::build::environment::cleanup() {
local container=$1
local volume=$2
local tmp_volume=$3
os::log::debug "Stopping container ${container}"
docker stop --time=0 "${container}" > /dev/null || true
if [[ -z "${OS_BUILD_ENV_LEAVE_CONTAINER:-}" ]]; then
os::log::debug "Removing container ${container}"
docker rm "${container}" > /dev/null
if [[ -n ${OS_BUILD_ENV_CLEAN_VOLUMES:-} ]]; then
os::build::environment::remove_volume ${volume}
os::build::environment::remove_volume ${tmp_volume}
fi
fi
}
readonly -f os::build::environment::cleanup
Expand Down Expand Up @@ -252,7 +258,7 @@ function os::build::environment::run() {

local container
container="$( os::build::environment::create "$@" )"
trap "os::build::environment::cleanup ${container}" EXIT
trap "os::build::environment::cleanup ${container} ${volume} ${tmp_volume}" EXIT

os::log::debug "Using container ${container}"

Expand Down

0 comments on commit 44102be

Please sign in to comment.