#!/bin/bash # Ideas Generator 2025 - Interactive Docker Setup Script # This script guides you through the complete deployment setup set -e # Colors for pretty output RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' BLUE='\033[0;34m' PURPLE='\033[0;35m' CYAN='\033[0;36m' NC='\033[0m' # No Color # Unicode symbols CHECKMARK="✅" ROCKET="🚀" GEAR="⚙️" KEY="🔑" DATABASE="🗄️" CLOUD="☁️" LOCK="🔒" GLOBE="🌐" print_header() { clear echo -e "${PURPLE}╔══════════════════════════════════════════════════════════════╗${NC}" echo -e "${PURPLE}║${NC} ${ROCKET} ${CYAN}Ideas Generator 2025 - Docker Deployment Setup${NC} ${PURPLE}║${NC}" echo -e "${PURPLE}╚══════════════════════════════════════════════════════════════╝${NC}" echo "" echo -e "${BLUE}This script will guide you through setting up your complete deployment.${NC}" echo -e "${BLUE}We'll configure everything needed for production deployment.${NC}" echo "" } print_section() { echo "" echo -e "${YELLOW}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}" echo -e "${CYAN}$1${NC}" echo -e "${YELLOW}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}" echo "" } ask_question() { local question="$1" local default="$2" local is_password="$3" local response if [ -n "$default" ]; then if [ "$is_password" = "password" ]; then echo -e "${BLUE}$question${NC} ${YELLOW}[default: ****]${NC}" printf "Enter value (or press Enter for default): " read -s response /dev/null || date +%s | sha256sum | base64 | head -c 32 } generate_jwt_secret() { openssl rand -base64 64 2>/dev/null || date +%s | sha256sum | base64 | head -c 64 } validate_email() { local email="$1" if [[ $email =~ ^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$ ]]; then return 0 else return 1 fi } # Main setup function main() { print_header echo -e "${GEAR} ${GREEN}Welcome to the Ideas Generator 2025 deployment setup!${NC}" echo "" echo "This wizard will collect all necessary configuration and generate your deployment files." echo "" echo "Press Enter to continue..." read .env << EOF # Ideas Generator 2025 - Docker Deployment Configuration # Generated on $(date) # Basic Configuration DOMAIN_NAME=$DOMAIN_NAME HTTP_PORT=$HTTP_PORT HTTPS_PORT=$HTTPS_PORT # Database Configuration DATABASE_NAME=$DATABASE_NAME DATABASE_USER=$DATABASE_USER DATABASE_PASSWORD=$DATABASE_PASSWORD # Security Configuration JWT_SECRET=$JWT_SECRET # Azure AD Configuration AZURE_TENANT_ID=$AZURE_TENANT_ID AZURE_CLIENT_ID=$AZURE_CLIENT_ID # OpenAI Configuration OPENAI_API_KEY=$OPENAI_API_KEY # URL Configuration FRONTEND_URL=$FRONTEND_URL BACKEND_URL=$BACKEND_URL CORS_ORIGIN=$CORS_ORIGIN # SSL Configuration SSL_CERT_PATH=$SSL_CERT_PATH EOF echo -e "${CHECKMARK} ${GREEN}.env file created successfully!${NC}" # Create docker-compose override for development if localhost if [ "$DOMAIN_NAME" == "localhost" ]; then cat > docker-compose.override.yml << EOF version: '3.8' # Development overrides for localhost deployment services: frontend: ports: - "$HTTP_PORT:80" environment: NGINX_HOST: localhost backend: environment: NODE_ENV: development EOF echo -e "${CHECKMARK} ${GREEN}docker-compose.override.yml created for development!${NC}" fi # Section 7: Final Instructions print_section "${ROCKET} Deployment Ready!" echo -e "${GREEN}Configuration completed successfully!${NC}" echo "" echo -e "${BLUE}Your configuration has been saved to:${NC}" echo -e " ${CYAN}.env${NC} - Main environment configuration" [ -f docker-compose.override.yml ] && echo -e " ${CYAN}docker-compose.override.yml${NC} - Development overrides" echo "" echo -e "${YELLOW}Next steps:${NC}" echo "" echo -e "${BLUE}1.${NC} Build and start the application:" echo -e " ${CYAN}docker-compose up -d --build${NC}" echo "" echo -e "${BLUE}2.${NC} Check the status of all services:" echo -e " ${CYAN}docker-compose ps${NC}" echo "" echo -e "${BLUE}3.${NC} View logs if needed:" echo -e " ${CYAN}docker-compose logs -f${NC}" echo "" echo -e "${BLUE}4.${NC} Access your application:" echo -e " ${CYAN}$FRONTEND_URL${NC}" echo "" if [ "$DOMAIN_NAME" != "localhost" ]; then echo -e "${YELLOW}Important for production deployment:${NC}" echo -e "${BLUE}•${NC} Ensure your SSL certificates are in: ${CYAN}$SSL_CERT_PATH${NC}" echo -e "${BLUE}•${NC} Configure your DNS to point to this server" echo -e "${BLUE}•${NC} Ensure ports $HTTP_PORT and $HTTPS_PORT are open in your firewall" echo "" fi echo -e "${LOCK} ${YELLOW}Security Notes:${NC}" echo -e "${BLUE}•${NC} Your .env file contains sensitive information - keep it secure" echo -e "${BLUE}•${NC} The admin user (daveporter@oliver.agency) will be created automatically" echo -e "${BLUE}•${NC} Password authentication is enabled by default but can be disabled via admin panel" echo "" echo -e "${CHECKMARK} ${GREEN}Setup complete! Your Ideas Generator 2025 is ready to deploy.${NC}" echo "" # Ask if user wants to start deployment now echo -e "${BLUE}Would you like to start the deployment now? (y/N): ${NC}" read start_now /dev/null; then missing_tools+=("docker") fi # Check for Docker Compose (either standalone or built-in) if ! command -v docker-compose &> /dev/null && ! docker compose version &> /dev/null; then missing_tools+=("docker-compose") fi if [ ${#missing_tools[@]} -ne 0 ]; then echo -e "${RED}Error: Missing required tools: ${missing_tools[*]}${NC}" echo "" echo "Please install Docker and Docker Compose before running this script." echo "Visit: https://docs.docker.com/get-docker/" exit 1 fi # Determine which Docker Compose command to use if command -v docker-compose &> /dev/null; then export DOCKER_COMPOSE_CMD="docker-compose" else export DOCKER_COMPOSE_CMD="docker compose" fi echo -e "${GREEN}✅ Docker found: $(docker --version)${NC}" echo -e "${GREEN}✅ Docker Compose found: $($DOCKER_COMPOSE_CMD version --short 2>/dev/null || echo "v2+")${NC}" } # Script entry point echo -e "${BLUE}Checking requirements...${NC}" check_requirements main exit 0