#!/usr/bin/env bash
set -euo pipefail

source ./scripts/Unix/starter.sh

# Shutdown services
log_step "Shutting down..."
if ! docker compose down; then
  log_error "Failed to shut down services"
  exit 1
fi
log_success "Services were shut down successfully!"

# Remove volumes
log_step "Removing volumes..."
docker volume rm -f evibes_prometheus-data || log_warning "Failed to remove prometheus-data volume"
docker volume rm -f evibes_es-data || log_warning "Failed to remove es-data volume"
log_success "Volumes were removed successfully!"

# Cleanup Docker
log_step "Cleaning up unused Docker data..."
if ! docker system prune -a -f --volumes; then
  log_warning "Docker cleanup had issues, but continuing..."
fi
log_success "Unused Docker data cleaned successfully!"

# Remove local files
log_step "Removing related files..."
rm -rf ./media ./static
log_success "Related files removed successfully!"

echo
log_result "Bye-bye, hope you return later!"
