Skip to content

Commit 44102be

Browse files
committed
Remove build docker volumes if OS_BUILD_ENV_CLEAN_VOLUMES is set.
1 parent 665899f commit 44102be

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

hack/lib/build/environment.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,17 @@ readonly -f os::build::environment::release::workingdir
9999
# (unless OS_BUILD_ENV_LEAVE_CONTAINER is set, in which case it will only stop the container).
100100
function os::build::environment::cleanup() {
101101
local container=$1
102+
local volume=$2
103+
local tmp_volume=$3
102104
os::log::debug "Stopping container ${container}"
103105
docker stop --time=0 "${container}" > /dev/null || true
104106
if [[ -z "${OS_BUILD_ENV_LEAVE_CONTAINER:-}" ]]; then
105107
os::log::debug "Removing container ${container}"
106108
docker rm "${container}" > /dev/null
109+
if [[ -n ${OS_BUILD_ENV_CLEAN_VOLUMES:-} ]]; then
110+
os::build::environment::remove_volume ${volume}
111+
os::build::environment::remove_volume ${tmp_volume}
112+
fi
107113
fi
108114
}
109115
readonly -f os::build::environment::cleanup
@@ -252,7 +258,7 @@ function os::build::environment::run() {
252258

253259
local container
254260
container="$( os::build::environment::create "$@" )"
255-
trap "os::build::environment::cleanup ${container}" EXIT
261+
trap "os::build::environment::cleanup ${container} ${volume} ${tmp_volume}" EXIT
256262

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

0 commit comments

Comments
 (0)