#!/usr/bin/env bash set -euo pipefail # Fully restart the dmtools stack for this checkout (testing or live). Scoped to # the compose project name, so running it from the test checkout never touches # the prod stack. # # ./docker/restart.sh # down + rebuildless bring-up via setup.sh # ./docker/restart.sh --prune-all # also run host-wide docker prune DOCKER_DIR=$(cd "$(dirname "$0")" && pwd) ROOT_DIR=$(cd "$DOCKER_DIR/.." && pwd) PROJECT=dmtools PRUNE_ALL=0 for arg in "$@"; do case "$arg" in --prune-all) PRUNE_ALL=1 ;; *) echo "Unknown option: $arg" >&2; exit 1 ;; esac done echo "Restarting stack: $PROJECT" (cd "$ROOT_DIR" && docker compose -p "$PROJECT" -f docker-compose.yml down --remove-orphans) || true docker rm -f dmtools-php dmtools-nginx dmtools-db 2>/dev/null || true for net in $(docker network ls -q --filter "name=^${PROJECT}_" 2>/dev/null); do docker network rm "$net" || true done if [ "$PRUNE_ALL" -eq 1 ]; then echo "Host-wide prune..." docker system prune -f || true docker builder prune -af || true else echo "Skipping host-wide prune (pass --prune-all to force it)." fi echo "Running setup script..." "$DOCKER_DIR/setup.sh" --no-build