ideas-generator/docker/quick-setup.sh
DJP cb29c9d1cf 🔧 Fix line endings in quick-setup.sh script
- Convert CRLF to LF line endings for Unix compatibility
- Script now works on macOS, Linux, and WSL environments
2025-09-09 18:37:17 -04:00

165 lines
No EOL
4.1 KiB
Bash
Executable file

#!/bin/bash
# Ideas Generator 2025 - Quick Setup Script
# Simplified version with better feedback
set -e
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
CYAN='\033[0;36m'
NC='\033[0m'
print_step() {
echo ""
echo -e "${CYAN}━━━ $1 ━━━${NC}"
echo ""
}
ask_with_default() {
local question="$1"
local default="$2"
local is_secret="$3"
if [ "$is_secret" = "secret" ]; then
echo -e "${BLUE}$question${NC}"
echo -e "Default: ${YELLOW}[hidden]${NC}"
printf "Enter value (or press Enter for default): "
read -s response
echo ""
else
echo -e "${BLUE}$question${NC}"
if [ -n "$default" ]; then
echo -e "Default: ${YELLOW}$default${NC}"
fi
printf "Enter value (or press Enter for default): "
read response
fi
if [ -z "$response" ] && [ -n "$default" ]; then
response="$default"
fi
echo "$response"
}
generate_password() {
openssl rand -base64 32 2>/dev/null || date +%s | sha256sum | base64 | head -c 32
}
generate_jwt() {
openssl rand -base64 64 2>/dev/null || date +%s | sha256sum | base64 | head -c 64
}
# Determine Docker Compose command
if command -v docker-compose &> /dev/null; then
COMPOSE="docker-compose"
else
COMPOSE="docker compose"
fi
clear
echo -e "${GREEN}🚀 Ideas Generator 2025 - Quick Docker Setup${NC}"
echo ""
echo "This will set up your deployment with sensible defaults."
echo "You can customize later by editing the .env file."
echo ""
read -p "Press Enter to continue or Ctrl+C to exit..."
# Basic Configuration
print_step "🌐 Basic Configuration"
DOMAIN=$(ask_with_default "Domain name for deployment?" "localhost")
HTTP_PORT=$(ask_with_default "HTTP port?" "80")
# Database Configuration
print_step "🗄️ Database Configuration"
DB_NAME=$(ask_with_default "Database name?" "ideas_gen_prod")
DB_USER=$(ask_with_default "Database user?" "ideas_admin")
DB_PASSWORD=$(ask_with_default "Database password?" "$(generate_password)" "secret")
# Security Configuration
print_step "🔐 Security Configuration"
JWT_SECRET=$(ask_with_default "JWT Secret?" "$(generate_jwt)" "secret")
# OpenAI Configuration
print_step "🤖 OpenAI Configuration"
while [ -z "$OPENAI_API_KEY" ]; do
OPENAI_API_KEY=$(ask_with_default "OpenAI API Key (required)?" "" "secret")
if [ -z "$OPENAI_API_KEY" ]; then
echo -e "${RED}OpenAI API Key is required!${NC}"
fi
done
# Azure AD Configuration
print_step "🏢 Azure AD Configuration"
AZURE_TENANT=$(ask_with_default "Azure Tenant ID?" "e519c2e6-bc6d-4fdf-8d9c-923c2f002385")
AZURE_CLIENT=$(ask_with_default "Azure Client ID?" "9079054c-9620-4757-a256-23413042f1ef")
# Generate configuration
print_step "📝 Generating Configuration"
echo "Creating .env file..."
cat > .env << EOF
# Ideas Generator 2025 - Configuration
# Generated: $(date)
DOMAIN_NAME=$DOMAIN
HTTP_PORT=$HTTP_PORT
HTTPS_PORT=443
DATABASE_NAME=$DB_NAME
DATABASE_USER=$DB_USER
DATABASE_PASSWORD=$DB_PASSWORD
JWT_SECRET=$JWT_SECRET
AZURE_TENANT_ID=$AZURE_TENANT
AZURE_CLIENT_ID=$AZURE_CLIENT
OPENAI_API_KEY=$OPENAI_API_KEY
FRONTEND_URL=http://$DOMAIN:$HTTP_PORT
BACKEND_URL=http://$DOMAIN:$HTTP_PORT/api
CORS_ORIGIN=http://$DOMAIN:$HTTP_PORT,http://localhost:$HTTP_PORT
SSL_CERT_PATH=./certs
EOF
echo -e "${GREEN}✅ Configuration saved to .env${NC}"
# Start deployment
print_step "🚀 Starting Deployment"
echo "Building and starting containers..."
echo "This may take a few minutes for the first build."
echo ""
$COMPOSE up -d --build
echo ""
echo -e "${GREEN}✅ Deployment Complete!${NC}"
echo ""
echo -e "${CYAN}Your Ideas Generator 2025 is now running at:${NC}"
echo -e "${YELLOW}http://$DOMAIN:$HTTP_PORT${NC}"
echo ""
echo -e "${BLUE}Useful commands:${NC}"
echo -e " View status: ${CYAN}$COMPOSE ps${NC}"
echo -e " View logs: ${CYAN}$COMPOSE logs -f${NC}"
echo -e " Stop: ${CYAN}$COMPOSE down${NC}"
echo -e " Restart: ${CYAN}$COMPOSE restart${NC}"
echo ""
# Show status
$COMPOSE ps
echo ""
echo -e "${GREEN}🎉 Setup complete!${NC}"