From 24739e3983b4ff27afaa4a9b4e7331190945947e Mon Sep 17 00:00:00 2001 From: pedro Date: Tue, 6 Feb 2024 14:29:14 +0100 Subject: [PATCH] add persistence flag, which by default is yes progress for #2 (resolves idhub persisten needs) and you have to explicitly say when you don't want it --- build__common.sh | 14 +++++++++++++- build__instance-autotest.sh | 5 ++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/build__common.sh b/build__common.sh index 8017886..5cd6ef8 100644 --- a/build__common.sh +++ b/build__common.sh @@ -10,6 +10,7 @@ common_start() { deployment="${1:-${deployment:-}}" action="${action:-deploy}" + persistence="${persistence:-y}" # detach on production deployment if [ "${deployment}" = 'prod' ]; then @@ -29,12 +30,23 @@ common_start() { idhub="${idhub:-idhub__${target}}" idhub1="${idhub1:-idhub1__${target}}" idhub2="${idhub2:-idhub2__${target}}" + + if [ "${persistence}" = "n" ]; then + # no data persistence: cleanup previous possible data + rm -rf "./${idhub}" + fi } common_end() { dc_file="docker-compose__${target}.yml" - docker compose -p ${target} -f ${dc_file} down -v || true + + if [ "${persistence}" = "n" ]; then + # no data persistence, then cleanup docker volume + vol_arg='-v' + fi + + docker compose -p ${target} -f ${dc_file} down ${vol_arg:-} || true make idhub_build if [ "${action:-}" = "deploy" ]; then diff --git a/build__instance-autotest.sh b/build__instance-autotest.sh index 94aaa01..f3d805c 100755 --- a/build__instance-autotest.sh +++ b/build__instance-autotest.sh @@ -17,10 +17,9 @@ main() { idhub="idhub__${target}" - common_start + persistence='n' - # no data persistence: cleanup previous possible data - rm -rf "./${idhub}" + common_start # detect if is new if [ ! -f "./${idhub}" ]; then