fix(scripts): preserve DB volume across rebuilds, stop nuking data

This commit is contained in:
null 2026-05-20 22:53:55 -05:00
parent 2060cf7d85
commit 328d71b0f8
1 changed files with 7 additions and 3 deletions

View File

@ -9,16 +9,20 @@
# IMPORTANT: Do not add global Docker cleanup here (e.g. `docker system prune`,
# `docker image prune`, `docker volume prune`). Those commands operate on
# ALL Docker resources system-wide and will destroy other running services.
#
# DATA PERSISTENCE: The postgres database volume is preserved across rebuilds.
# Only app containers/images are cycled. DB data (gateways, keys, etc.) survives.
set -euo pipefail
cd "$(git rev-parse --show-toplevel)"
PROJECT_NAME="$(docker compose config --format '{{.Name}}' 2>/dev/null || echo 'pipeline')"
echo "=== Compose project: ${PROJECT_NAME} ==="
echo "=== Stopping and removing ONLY ${PROJECT_NAME} containers, images, volumes ==="
echo "=== Stopping ${PROJECT_NAME} containers (preserving database volume) ==="
# Scoped to this compose project only — does NOT affect other containers.
docker compose down --rmi all --volumes --remove-orphans 2>/dev/null || true
# Stop and remove containers only — no --volumes (preserve postgres data),
# no --rmi all (preserve pulled base images). Just rebuild the app images.
docker compose down --remove-orphans 2>/dev/null || true
echo "=== Building and starting all containers ==="
docker compose up --build -d