Convenience scripts for Docker Compose management:
start.sh:
• Checks Docker prerequisites
• Creates .env from template if missing
• Builds Docker images
• Starts all services
• Verifies service health
• Displays access information
stop.sh:
• Graceful service shutdown options
• Option 1: Stop containers (preserve data)
• Option 2: Stop and remove containers
• Option 3: Complete cleanup (remove all data)
Usage:
./start.sh - Start the entire system
./stop.sh - Stop services interactively
Features:
✓ Color-coded output for clarity
✓ Error checking and helpful messages
✓ Prerequisites validation
✓ Automatic .env setup
✓ Health verification
✓ Quick access information
🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>
71 lines
1.7 KiB
Bash
Executable File
71 lines
1.7 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# ================================================================
|
|
# E-Voting System - Docker Compose Stop Script
|
|
# ================================================================
|
|
|
|
set -e
|
|
|
|
# Colors
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
BLUE='\033[0;34m'
|
|
NC='\033[0m'
|
|
|
|
print_header() {
|
|
echo -e "${BLUE}================================${NC}"
|
|
echo -e "${BLUE}$1${NC}"
|
|
echo -e "${BLUE}================================${NC}"
|
|
}
|
|
|
|
print_success() {
|
|
echo -e "${GREEN}✓ $1${NC}"
|
|
}
|
|
|
|
print_warning() {
|
|
echo -e "${YELLOW}! $1${NC}"
|
|
}
|
|
|
|
# Main
|
|
print_header "E-Voting System - Stopping Services"
|
|
|
|
echo ""
|
|
echo "Options:"
|
|
echo " 1. Stop services (containers kept)"
|
|
echo " 2. Stop and remove containers"
|
|
echo " 3. Stop and remove everything (including data)"
|
|
echo ""
|
|
read -p "Select option (1-3): " option
|
|
|
|
case $option in
|
|
1)
|
|
print_warning "Stopping containers..."
|
|
docker-compose stop
|
|
print_success "Services stopped (data preserved)"
|
|
echo ""
|
|
echo "To start again: docker-compose up -d"
|
|
;;
|
|
2)
|
|
print_warning "Stopping and removing containers..."
|
|
docker-compose down
|
|
print_success "Containers removed (data preserved)"
|
|
echo ""
|
|
echo "To start again: docker-compose up -d"
|
|
;;
|
|
3)
|
|
print_warning "This will DELETE all data!"
|
|
read -p "Are you sure? (yes/no): " confirm
|
|
if [ "$confirm" = "yes" ]; then
|
|
docker-compose down -v
|
|
print_success "Services stopped and all data deleted"
|
|
else
|
|
print_warning "Cancelled"
|
|
fi
|
|
;;
|
|
*)
|
|
print_warning "Invalid option"
|
|
exit 1
|
|
;;
|
|
esac
|