File size: 1,525 Bytes
ff7384a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash

# Script to clean up LegisQA Docker containers and images

IMAGE_NAME="legisqa-local"
CONTAINER_NAME="legisqa-container"

echo "🧹 Cleaning up LegisQA Docker resources..."
echo ""

# Stop and remove the running container if it exists
echo "Stopping container: $CONTAINER_NAME"
if docker stop $CONTAINER_NAME 2>/dev/null; then
    echo "✅ Container $CONTAINER_NAME stopped"
else
    echo "ℹ️  Container $CONTAINER_NAME not running"
fi

echo ""

# Remove the container if it exists (in case it's stopped but not removed)
echo "Removing container: $CONTAINER_NAME"
if docker rm $CONTAINER_NAME 2>/dev/null; then
    echo "✅ Container $CONTAINER_NAME removed"
else
    echo "ℹ️  Container $CONTAINER_NAME not found"
fi

echo ""

# Remove the image if it exists
echo "Removing image: $IMAGE_NAME"
if docker rmi $IMAGE_NAME 2>/dev/null; then
    echo "✅ Image $IMAGE_NAME removed"
else
    echo "ℹ️  Image $IMAGE_NAME not found"
fi

echo ""

# Optional: Clean up dangling images and build cache
read -p "🗑️  Clean up dangling images and build cache? (y/N): " -n 1 -r
echo ""
if [[ $REPLY =~ ^[Yy]$ ]]; then
    echo "Cleaning up dangling images..."
    docker image prune -f
    echo "Cleaning up build cache..."
    docker builder prune -f
    echo "✅ Cleanup complete!"
else
    echo "ℹ️  Skipped cleanup of dangling images and build cache"
fi

echo ""
echo "🎉 LegisQA Docker cleanup finished!"
echo ""
echo "To rebuild and run:"
echo "  ./build-docker.sh"
echo "  ./run-docker.sh"