#!/bin/bash # Discord Fishbowl Docker Services Management Script set -e # Colors for output RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' NC='\033[0m' # No Color COMPOSE_FILE="docker-compose.services.yml" ENV_FILE=".env.docker" print_usage() { echo "Discord Fishbowl Docker Services Manager" echo "" echo "Usage: $0 {start|stop|restart|status|logs|admin|chromadb|qdrant|clean}" echo "" echo "Commands:" echo " start - Start PostgreSQL and Redis services" echo " stop - Stop all services" echo " restart - Restart all services" echo " status - Show service status" echo " logs - Show service logs" echo " admin - Start with PgAdmin (database admin interface)" echo " chromadb - Start with ChromaDB vector database" echo " qdrant - Start with Qdrant vector database" echo " clean - Stop services and remove volumes (WARNING: deletes data)" echo "" } check_requirements() { if ! command -v docker &> /dev/null; then echo -e "${RED}Error: Docker is not installed${NC}" exit 1 fi if ! docker compose version &> /dev/null; then echo -e "${RED}Error: Docker Compose is not available${NC}" exit 1 fi if [ ! -f "$COMPOSE_FILE" ]; then echo -e "${RED}Error: $COMPOSE_FILE not found${NC}" exit 1 fi } start_services() { echo -e "${GREEN}๐Ÿ  Starting Discord Fishbowl services...${NC}" if [ ! -f "$ENV_FILE" ]; then echo -e "${YELLOW}Creating default environment file...${NC}" cat > "$ENV_FILE" << EOF # Default Docker environment DB_PASSWORD=fishbowl_password REDIS_PASSWORD=redis_password PGADMIN_PASSWORD=admin123 EOF fi docker compose -f "$COMPOSE_FILE" --env-file "$ENV_FILE" up -d echo -e "${GREEN}โœ… Services started successfully!${NC}" echo "" echo "Services available at:" echo " ๐Ÿ“Š PostgreSQL: localhost:15432" echo " ๐Ÿ”ด Redis: localhost:6379" echo "" echo "Run '$0 status' to check service health" echo "Use '$0 chromadb' or '$0 qdrant' to add vector database" } start_with_admin() { echo -e "${GREEN}๐Ÿ  Starting Discord Fishbowl services with PgAdmin...${NC}" if [ ! -f "$ENV_FILE" ]; then echo -e "${YELLOW}Creating default environment file...${NC}" cat > "$ENV_FILE" << EOF # Default Docker environment DB_PASSWORD=fishbowl_password REDIS_PASSWORD=redis_password PGADMIN_PASSWORD=admin123 EOF fi docker compose -f "$COMPOSE_FILE" --env-file "$ENV_FILE" --profile admin up -d echo -e "${GREEN}โœ… Services started successfully!${NC}" echo "" echo "Services available at:" echo " ๐Ÿ“Š PostgreSQL: localhost:15432" echo " ๐Ÿ”ด Redis: localhost:6379" echo " ๐Ÿง  ChromaDB: http://localhost:8000" echo " ๐ŸŒ PgAdmin: http://localhost:8080" echo " Login: admin@fishbowl.dev / admin123" echo "" } start_with_chromadb() { echo -e "${GREEN}๐Ÿ  Starting Discord Fishbowl services with ChromaDB...${NC}" if [ ! -f "$ENV_FILE" ]; then echo -e "${YELLOW}Creating default environment file...${NC}" cat > "$ENV_FILE" << EOF # Default Docker environment DB_PASSWORD=fishbowl_password REDIS_PASSWORD=redis_password PGADMIN_PASSWORD=admin123 EOF fi docker compose -f "$COMPOSE_FILE" --env-file "$ENV_FILE" --profile chromadb up -d echo -e "${GREEN}โœ… Services started successfully!${NC}" echo "" echo "Services available at:" echo " ๐Ÿ“Š PostgreSQL: localhost:15432" echo " ๐Ÿ”ด Redis: localhost:6379" echo " ๐Ÿง  ChromaDB: http://localhost:8000" echo "" } start_with_qdrant() { echo -e "${GREEN}๐Ÿ  Starting Discord Fishbowl services with Qdrant...${NC}" if [ ! -f "$ENV_FILE" ]; then echo -e "${YELLOW}Creating default environment file...${NC}" cat > "$ENV_FILE" << EOF # Default Docker environment DB_PASSWORD=fishbowl_password REDIS_PASSWORD=redis_password PGADMIN_PASSWORD=admin123 EOF fi docker compose -f "$COMPOSE_FILE" --env-file "$ENV_FILE" --profile qdrant up -d echo -e "${GREEN}โœ… Services started successfully!${NC}" echo "" echo "Services available at:" echo " ๐Ÿ“Š PostgreSQL: localhost:15432" echo " ๐Ÿ”ด Redis: localhost:6379" echo " ๐Ÿ” Qdrant: http://localhost:6333" echo " Dashboard: http://localhost:6333/dashboard" echo "" } stop_services() { echo -e "${YELLOW}๐Ÿ›‘ Stopping Discord Fishbowl services...${NC}" docker compose -f "$COMPOSE_FILE" down echo -e "${GREEN}โœ… Services stopped${NC}" } restart_services() { stop_services sleep 2 start_services } show_status() { echo -e "${GREEN}๐Ÿ“Š Discord Fishbowl Service Status${NC}" echo "" docker compose -f "$COMPOSE_FILE" ps echo "" # Check health echo "Health checks:" for service in postgres redis chromadb; do if docker compose -f "$COMPOSE_FILE" ps --services --filter "status=running" | grep -q "$service"; then echo -e " ${GREEN}โœ… $service: Running${NC}" else echo -e " ${RED}โŒ $service: Not running${NC}" fi done } show_logs() { echo -e "${GREEN}๐Ÿ“‹ Service Logs${NC}" docker compose -f "$COMPOSE_FILE" logs -f } clean_services() { echo -e "${RED}โš ๏ธ WARNING: This will delete all data in PostgreSQL, Redis, and ChromaDB!${NC}" read -p "Are you sure? Type 'yes' to continue: " confirm if [ "$confirm" = "yes" ]; then echo -e "${YELLOW}๐Ÿงน Cleaning up services and data...${NC}" docker compose -f "$COMPOSE_FILE" down -v echo -e "${GREEN}โœ… Cleanup complete${NC}" else echo -e "${YELLOW}Cleanup cancelled${NC}" fi } # Main script check_requirements case "${1:-}" in start) start_services ;; stop) stop_services ;; restart) restart_services ;; status) show_status ;; logs) show_logs ;; admin) start_with_admin ;; chromadb) start_with_chromadb ;; qdrant) start_with_qdrant ;; clean) clean_services ;; *) print_usage exit 1 ;; esac