diff --git a/docker-compose.yml b/docker-compose.yml index 313b23e0..0fc5a211 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -107,6 +107,11 @@ services: redis: image: redis:7-alpine + # In memory. The image declares a volume at /data, so without a mount there each new + # container got a new anonymous volume, which `docker compose down` left behind. Redis holds + # only the broker's queue and the app's short-lived keys, which it can lose. + tmpfs: + - /data healthcheck: test: ["CMD", "redis-cli", "ping"] interval: 5s diff --git a/scripts/local_sanitize_backup.sh b/scripts/local_sanitize_backup.sh index 4dcf59b4..818c6169 100755 --- a/scripts/local_sanitize_backup.sh +++ b/scripts/local_sanitize_backup.sh @@ -78,7 +78,9 @@ DB_URL="postgres://postgres:postgres@localhost:${PORT}/${DB_NAME}" cleanup() { if [[ $CONTAINER_STARTED -eq 1 ]]; then echo "Stopping container ${CONTAINER}..." - docker rm -f "$CONTAINER" >/dev/null 2>&1 || true + # -v: --rm deletes the data volume only when the container stops on its own, and removing + # it here would otherwise leave a copy of the restored database behind. + docker rm -f -v "$CONTAINER" >/dev/null 2>&1 || true fi } trap cleanup EXIT diff --git a/scripts/test_download_s3_dump.sh b/scripts/test_download_s3_dump.sh index 6ac91032..2134caa8 100755 --- a/scripts/test_download_s3_dump.sh +++ b/scripts/test_download_s3_dump.sh @@ -25,7 +25,8 @@ LARGE_DUMP_BYTES=$((9 * 1024 * 1024)) run="qb-s3-dump-test-$$" work="$(mktemp -d)" cleanup() { - docker rm -f "$run-s3" "$run-pg18" "$run-pg17" >/dev/null 2>&1 || true + # -v: with their anonymous volumes, such as each Postgres's data directory. + docker rm -f -v "$run-s3" "$run-pg18" "$run-pg17" >/dev/null 2>&1 || true rm -rf "$work" } trap cleanup EXIT