#!/bin/bash # Ideas Generator 2025 - Deployment Management Script # Simplified deployment commands set -e # Colors GREEN='\033[0;32m' BLUE='\033[0;34m' YELLOW='\033[1;33m' RED='\033[0;31m' NC='\033[0m' # Navigate to docker directory cd "$(dirname "$0")/.." # Determine which Docker Compose command to use if command -v docker-compose &> /dev/null; then DOCKER_COMPOSE="docker-compose" else DOCKER_COMPOSE="docker compose" fi print_usage() { echo -e "${BLUE}Ideas Generator 2025 - Deployment Management${NC}" echo "" echo "Usage: $0 [command]" echo "" echo "Commands:" echo " start Start all services" echo " stop Stop all services" echo " restart Restart all services" echo " build Build and start with latest changes" echo " status Show status of all services" echo " logs Show logs from all services" echo " logs [service] Show logs from specific service" echo " shell [service] Open shell in running service" echo " update Pull latest images and restart" echo " backup Backup database" echo " cleanup Remove unused containers and images" echo "" } case "$1" in start) echo -e "${GREEN}๐Ÿš€ Starting Ideas Generator 2025...${NC}" $DOCKER_COMPOSE up -d echo -e "${GREEN}โœ… Services started!${NC}" $DOCKER_COMPOSE ps ;; stop) echo -e "${YELLOW}โน๏ธ Stopping Ideas Generator 2025...${NC}" $DOCKER_COMPOSE down echo -e "${GREEN}โœ… Services stopped!${NC}" ;; restart) echo -e "${YELLOW}๐Ÿ”„ Restarting Ideas Generator 2025...${NC}" $DOCKER_COMPOSE restart echo -e "${GREEN}โœ… Services restarted!${NC}" $DOCKER_COMPOSE ps ;; build) echo -e "${BLUE}๐Ÿ—๏ธ Building and starting Ideas Generator 2025...${NC}" $DOCKER_COMPOSE up -d --build echo -e "${GREEN}โœ… Build complete and services started!${NC}" $DOCKER_COMPOSE ps ;; status) echo -e "${BLUE}๐Ÿ“Š Ideas Generator 2025 Status:${NC}" $DOCKER_COMPOSE ps ;; logs) if [ -n "$2" ]; then echo -e "${BLUE}๐Ÿ“‹ Showing logs for $2:${NC}" $DOCKER_COMPOSE logs -f "$2" else echo -e "${BLUE}๐Ÿ“‹ Showing logs for all services:${NC}" $DOCKER_COMPOSE logs -f fi ;; shell) if [ -n "$2" ]; then echo -e "${BLUE}๐Ÿ”ง Opening shell in $2:${NC}" $DOCKER_COMPOSE exec "$2" sh else echo -e "${RED}โŒ Please specify a service: backend, frontend, or database${NC}" exit 1 fi ;; update) echo -e "${BLUE}๐Ÿ”„ Updating Ideas Generator 2025...${NC}" $DOCKER_COMPOSE pull $DOCKER_COMPOSE up -d --build echo -e "${GREEN}โœ… Update complete!${NC}" $DOCKER_COMPOSE ps ;; backup) echo -e "${BLUE}๐Ÿ’พ Creating database backup...${NC}" BACKUP_FILE="backup_$(date +%Y%m%d_%H%M%S).sql" $DOCKER_COMPOSE exec database pg_dump -U ideas_admin ideas_gen_prod > "$BACKUP_FILE" echo -e "${GREEN}โœ… Database backup saved to: $BACKUP_FILE${NC}" ;; cleanup) echo -e "${YELLOW}๐Ÿงน Cleaning up unused Docker resources...${NC}" docker system prune -f docker volume prune -f echo -e "${GREEN}โœ… Cleanup complete!${NC}" ;; *) print_usage exit 1 ;; esac