From c4c02dffda48da3090df05c7408019fe238e38c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre-Etienne=20Bougu=C3=A9?= Date: Wed, 4 Dec 2024 18:40:58 +0100 Subject: [PATCH] script: docker: remove docker images of the tested PR when cleaning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Saves disk resources (and forces re-pull, which may be useful for new version) Signed-off-by: Pierre-Etienne Bougué --- scripts/cleanup-db.sh | 2 +- scripts/load-backup.sh | 2 +- scripts/pr-tests-compose.sh | 12 +++++++++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/scripts/cleanup-db.sh b/scripts/cleanup-db.sh index ddb4467f1e8..fc5131528ad 100755 --- a/scripts/cleanup-db.sh +++ b/scripts/cleanup-db.sh @@ -23,7 +23,7 @@ OSRD_VALKEY="osrd-valkey" OSRD_VALKEY_VOLUME="osrd_valkey_data" OSRD_POSTGRES_PORT=5432 OSRD_VALKEY_PORT=6379 -if [ "$PR_TEST" -eq 1 ]; then +if [ "$PR_TEST" = 1 ]; then OSRD_POSTGRES="osrd-postgres-pr-tests" OSRD_EDITOAST="osrd-editoast-pr-tests" OSRD_VALKEY="osrd-valkey-pr-tests" diff --git a/scripts/load-backup.sh b/scripts/load-backup.sh index 564cbc3b51e..1229dde708e 100755 --- a/scripts/load-backup.sh +++ b/scripts/load-backup.sh @@ -41,7 +41,7 @@ fi # These variables are necessary to load the infra on the correct instance (the pr-infra or the dev one) OSRD_POSTGRES="osrd-postgres" OSRD_POSTGRES_PORT=5432 -if [ "$PR_TEST" -eq 1 ]; then +if [ "$PR_TEST" = 1 ]; then OSRD_POSTGRES="osrd-postgres-pr-tests" OSRD_POSTGRES_PORT=5433 fi diff --git a/scripts/pr-tests-compose.sh b/scripts/pr-tests-compose.sh index d974243ee67..3b18c3ceaa0 100755 --- a/scripts/pr-tests-compose.sh +++ b/scripts/pr-tests-compose.sh @@ -74,10 +74,20 @@ elif [ "$1" = "down" ]; then else - # Shutdown and clean the docker instance + # Shutdown and clean the docker instance (remove "osrd" images too) + osrd_images=$(docker compose \ + -p "osrd-pr-tests" \ + -f "docker/docker-compose.pr-tests.yml" \ + images --format json \ + core editoast osrdyne gateway front \ + | jq --raw-output '.[].ID') + docker compose \ -p "osrd-pr-tests" \ -f "docker/docker-compose.pr-tests.yml" \ down -v + # shellcheck disable=SC2086 + docker rmi ${osrd_images} + fi