Add service profiles to docker-compose.yml and implement service selection wizard

- Added profiles for various services in docker-compose.yml to enhance service management.
- Introduced a new interactive wizard script (04_wizard.sh) for user-friendly service selection during installation.
- Updated installation script (install.sh) to incorporate the service selection process.
- Added final report script (06_final_report.sh) to summarize installation steps and provide access credentials.
- Enhanced system preparation script (01_system_preparation.sh) by including 'whiptail' for the wizard functionality.
This commit is contained in:
Yury Kossakovsky
2025-05-09 15:24:13 -06:00
parent 26fedd1faa
commit b7ff4399d1
6 changed files with 147 additions and 5 deletions

View File

@@ -41,6 +41,7 @@ services:
image: flowiseai/flowise
restart: unless-stopped
container_name: flowise
profiles: ["flowise"]
environment:
- PORT=3001
- FLOWISE_USERNAME
@@ -55,6 +56,7 @@ services:
image: ghcr.io/open-webui/open-webui:main
restart: unless-stopped
container_name: open-webui
profiles: ["open-webui"]
extra_hosts:
- "host.docker.internal:host-gateway"
volumes:
@@ -63,6 +65,7 @@ services:
n8n-import:
<<: *service-n8n
container_name: n8n-import
profiles: ["n8n"]
environment:
<<: *service-n8n-env
RUN_N8N_IMPORT: ${RUN_N8N_IMPORT:-false}
@@ -78,6 +81,7 @@ services:
n8n:
<<: *service-n8n
container_name: n8n
profiles: ["n8n"]
restart: unless-stopped
volumes:
- n8n_storage:/home/node/.n8n
@@ -90,6 +94,7 @@ services:
n8n-worker:
<<: *service-n8n
container_name: n8n-worker
profiles: ["n8n"]
restart: unless-stopped
command: worker
volumes:
@@ -106,6 +111,7 @@ services:
qdrant:
image: qdrant/qdrant
container_name: qdrant
profiles: ["qdrant"]
restart: unless-stopped
volumes:
- qdrant_storage:/qdrant/storage
@@ -148,6 +154,7 @@ services:
langfuse-worker:
image: langfuse/langfuse-worker:3
restart: always
profiles: ["langfuse"]
depends_on: &langfuse-depends-on
postgres:
condition: service_healthy
@@ -204,6 +211,7 @@ services:
langfuse-web:
image: langfuse/langfuse:3
restart: always
profiles: ["langfuse"]
depends_on: *langfuse-depends-on
environment:
<<: *langfuse-worker-env
@@ -223,6 +231,7 @@ services:
clickhouse:
image: clickhouse/clickhouse-server
restart: always
profiles: ["langfuse"]
user: "101:101"
environment:
CLICKHOUSE_DB: default
@@ -241,6 +250,7 @@ services:
minio:
image: minio/minio
restart: always
profiles: ["langfuse"]
entrypoint: sh
# create the 'langfuse' bucket before starting the service
command: -c 'mkdir -p /data/langfuse && minio server --address ":9000" --console-address ":9001" /data'
@@ -298,6 +308,7 @@ services:
searxng:
container_name: searxng
image: docker.io/searxng/searxng:latest
profiles: ["searxng"]
restart: unless-stopped
volumes:
- ./searxng:/etc/searxng:rw
@@ -320,6 +331,7 @@ services:
prometheus:
image: prom/prometheus:latest
container_name: prometheus
profiles: ["monitoring"]
restart: unless-stopped
volumes:
- ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro
@@ -330,6 +342,7 @@ services:
node-exporter:
image: prom/node-exporter:latest
container_name: node-exporter
profiles: ["monitoring"]
restart: unless-stopped
volumes:
- /proc:/host/proc:ro
@@ -345,6 +358,7 @@ services:
cadvisor:
image: gcr.io/cadvisor/cadvisor:latest
container_name: cadvisor
profiles: ["monitoring"]
restart: unless-stopped
volumes:
- /:/rootfs:ro
@@ -357,6 +371,7 @@ services:
grafana:
image: grafana/grafana:latest
container_name: grafana
profiles: ["monitoring"]
restart: unless-stopped
environment:
- GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_ADMIN_PASSWORD:-admin}
@@ -373,6 +388,7 @@ services:
crawl4ai:
image: unclecode/crawl4ai:latest # Use official image
container_name: crawl4ai
profiles: ["crawl4ai"]
restart: unless-stopped
shm_size: 1g # Recommended for browser operations
env_file:

View File

@@ -14,7 +14,7 @@ apt update -y && apt upgrade -y
# Installing Basic Utilities
log_info "Installing standard CLI tools..."
apt install -y \
htop git curl make unzip ufw fail2ban python3 psmisc \
htop git curl make unzip ufw fail2ban python3 psmisc whiptail \
build-essential ca-certificates gnupg lsb-release openssl \
debian-keyring debian-archive-keyring apt-transport-https

118
scripts/04_wizard.sh Normal file
View File

@@ -0,0 +1,118 @@
#!/bin/bash
# Script to guide user through service selection for n8n-installer
# Source utility functions, if any, assuming it's in the same directory
# and .env is in the parent directory
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
ENV_FILE="$PROJECT_ROOT/.env"
# UTILS_SCRIPT="$SCRIPT_DIR/utils.sh" # Uncomment if utils.sh contains relevant functions
# if [ -f "$UTILS_SCRIPT" ]; then
# source "$UTILS_SCRIPT"
# fi
# Function to check if whiptail is installed
check_whiptail() {
if ! command -v whiptail &> /dev/null; then
echo "--------------------------------------------------------------------"
echo "ERROR: 'whiptail' is not installed."
echo "This tool is required for the interactive service selection."
echo "On Debian/Ubuntu, you can install it using: sudo apt-get install whiptail"
echo "Please install whiptail and try again."
echo "--------------------------------------------------------------------"
exit 1
fi
}
# Call the check
check_whiptail
# Define available services and their descriptions for the checklist
# Format: "tag" "description" "ON/OFF"
# Caddy, Postgres, and Redis are core services and will always be enabled implicitly
# if dependent services are chosen, or by default as they won't have profiles.
services=(
"n8n" "n8n, n8n-worker, n8n-import (Workflow Automation)" "ON"
"flowise" "Flowise (AI Agent Builder)" "ON"
"open-webui" "Open WebUI (ChatGPT-like Interface)" "ON"
"qdrant" "Qdrant (Vector Database)" "ON"
"langfuse" "Langfuse Suite (AI Observability - includes Clickhouse, Minio)" "ON"
"searxng" "SearXNG (Private Metasearch Engine)" "ON"
"monitoring" "Monitoring Suite (Prometheus, Grafana, cAdvisor, Node-Exporter)" "ON"
"crawl4ai" "Crawl4ai (Web Crawler for AI)" "ON"
)
# Use whiptail to display the checklist
CHOICES=$(whiptail --title "Service Selection Wizard" --checklist \\
"Choose the services you want to deploy.\\nUse ARROW KEYS to navigate, SPACEBAR to select/deselect, ENTER to confirm." 22 78 10 \\
"${services[@]}" 3>&1 1>&2 2>&3)
# Exit if user pressed Cancel or Esc
exitstatus=$?
if [ $exitstatus -ne 0 ]; then
echo "--------------------------------------------------------------------"
echo "INFO: Service selection cancelled by user. Exiting wizard."
echo "No changes made to service profiles. Default services will be used."
echo "--------------------------------------------------------------------"
# Set COMPOSE_PROFILES to empty to ensure only core services run
if [ ! -f "$ENV_FILE" ]; then
touch "$ENV_FILE"
fi
if grep -q "^COMPOSE_PROFILES=" "$ENV_FILE"; then
sed -i.bak "/^COMPOSE_PROFILES=/d" "$ENV_FILE"
fi
echo "COMPOSE_PROFILES=" >> "$ENV_FILE"
exit 0
fi
# Process selected services
selected_profiles=()
if [ -n "$CHOICES" ]; then
# Whiptail returns a string like "tag1" "tag2" "tag3"
# We need to remove quotes and convert to an array
eval "selected_profiles=($CHOICES)"
fi
echo "--------------------------------------------------------------------"
if [ ${#selected_profiles[@]} -eq 0 ]; then
echo "INFO: No optional services selected."
COMPOSE_PROFILES_VALUE=""
else
echo "INFO: You have selected the following service profiles to be deployed:"
# Join the array into a comma-separated string
COMPOSE_PROFILES_VALUE=$(IFS=,; echo "${selected_profiles[*]}")
for profile in "${selected_profiles[@]}"; do
echo " - $profile"
done
fi
echo "--------------------------------------------------------------------"
# Update or add COMPOSE_PROFILES in .env file
# Ensure .env file exists (it should have been created by 03_generate_secrets.sh)
if [ ! -f "$ENV_FILE" ]; then
echo "WARNING: '.env' file not found at $ENV_FILE. Creating it."
touch "$ENV_FILE"
fi
# Remove existing COMPOSE_PROFILES line if it exists
if grep -q "^COMPOSE_PROFILES=" "$ENV_FILE"; then
# Using a different delimiter for sed because a profile name might contain '/' (unlikely here)
sed -i.bak "\|^COMPOSE_PROFILES=|d" "$ENV_FILE"
fi
# Add the new COMPOSE_PROFILES line
echo "COMPOSE_PROFILES=${COMPOSE_PROFILES_VALUE}" >> "$ENV_FILE"
echo "INFO: COMPOSE_PROFILES has been set in '$ENV_FILE'."
if [ -z "$COMPOSE_PROFILES_VALUE" ]; then
echo "Only core services (Caddy, Postgres, Redis) will be started."
else
echo "The following Docker Compose profiles will be active: ${COMPOSE_PROFILES_VALUE}"
fi
echo "--------------------------------------------------------------------"
# Make the script executable (though install.sh calls it with bash)
chmod +x "$SCRIPT_DIR/00_wizard.sh"
exit 0

View File

@@ -10,6 +10,7 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
# Check if all required scripts exist and are executable in the current directory
required_scripts=(
"00_wizard.sh"
"01_system_preparation.sh"
"02_install_docker.sh"
"03_generate_secrets.sh"
@@ -56,6 +57,7 @@ if [ ${#non_executable_scripts[@]} -gt 0 ]; then
fi
# Run installation steps sequentially using their full paths
log_info "Step 1: System Preparation..."
bash "$SCRIPT_DIR/01_system_preparation.sh" || { log_error "System Preparation failed"; exit 1; }
log_success "System preparation complete!"
@@ -68,12 +70,18 @@ log_info "Step 3: Generating Secrets and Configuration..."
bash "$SCRIPT_DIR/03_generate_secrets.sh" || { log_error "Secret/Config Generation failed"; exit 1; }
log_success "Secret/Config Generation complete!"
log_info "Step 4: Running Services..."
bash "$SCRIPT_DIR/04_run_services.sh" || { log_error "Running Services failed"; exit 1; }
log_info "Step 4: Running Service Selection Wizard..."
bash "$SCRIPT_DIR/04_wizard.sh" || { log_error "Service Selection Wizard failed"; exit 1; }
log_success "Service Selection Wizard complete!"
log_info "Step 5: Running Services..."
bash "$SCRIPT_DIR/05_run_services.sh" || { log_error "Running Services failed"; exit 1; }
log_success "Running Services complete!"
log_info "Step 5: Generating Final Report..."
bash "$SCRIPT_DIR/05_final_report.sh" || { log_error "Final Report Generation failed"; exit 1; }
log_info "Step 6: Generating Final Report..."
bash "$SCRIPT_DIR/06_final_report.sh" || { log_error "Final Report Generation failed"; exit 1; }
log_success "Final Report Generation complete!"
log_message "SUCCESS" "Installation process completed!"
exit 0