Add MailHog email testing and improve services.yaml configuration
This commit adds comprehensive email testing support and improves the Homepage dashboard configuration logic: MailHog Email Testing: - Add MailHog service with configurable SMTP and Web UI ports - Configure MailHog ports in config.sh with defaults (1025 SMTP, 8025 Web) - Add port conflict checking for MailHog ports - Use environment variables for MailHog ports in docker-compose.yml Enhanced Homepage Configuration: - Improve update_services_yaml() function to handle Production and Local tabs separately - Add local IP address configuration prompt for Homepage Local tab - Support custom local network IPs (e.g., Tailscale) for local service access - Add comprehensive port-based URL mappings for all services in Local tab - Include MailHog in both Production and Local service mappings Configuration Improvements: - Add local_ip parameter to update_services_yaml function - Display MailHog information in port summary and next steps - Update completion message with Homepage Local tab configuration info These changes enable developers to test email functionality locally and provide better support for accessing services via local network IPs.
This commit is contained in:
parent
73b0e31847
commit
bffb2dd74d
163
config.sh
163
config.sh
@ -272,6 +272,8 @@ initialize_available_ports() {
|
||||
["REDIS_EXPORTER_PORT"]=9121
|
||||
["ALERTMANAGER_PORT"]=9093
|
||||
["GOTIFY_PORT"]=8889
|
||||
["MAILHOG_SMTP_PORT"]=1025
|
||||
["MAILHOG_WEB_PORT"]=8025
|
||||
)
|
||||
|
||||
# Find available ports for each service
|
||||
@ -353,6 +355,10 @@ REDIS_EXPORTER_PORT=${REDIS_EXPORTER_PORT:-9121}
|
||||
ALERTMANAGER_PORT=${ALERTMANAGER_PORT:-9093}
|
||||
GOTIFY_PORT=${GOTIFY_PORT:-8889}
|
||||
|
||||
# MailHog Email Testing Ports
|
||||
MAILHOG_SMTP_PORT=${MAILHOG_SMTP_PORT:-1025}
|
||||
MAILHOG_WEB_PORT=${MAILHOG_WEB_PORT:-8025}
|
||||
|
||||
# Domain Configuration
|
||||
BASE_DOMAIN=https://changeme.org
|
||||
DOMAIN=changeme.org
|
||||
@ -467,6 +473,10 @@ EOL
|
||||
echo "Redis Exporter: ${REDIS_EXPORTER_PORT:-9121}"
|
||||
echo "Alertmanager: ${ALERTMANAGER_PORT:-9093}"
|
||||
echo "Gotify: ${GOTIFY_PORT:-8889}"
|
||||
echo ""
|
||||
echo "=== Email Testing ==="
|
||||
echo "MailHog SMTP: ${MAILHOG_SMTP_PORT:-1025}"
|
||||
echo "MailHog Web: ${MAILHOG_WEB_PORT:-8025}"
|
||||
echo "================================"
|
||||
}
|
||||
|
||||
@ -502,31 +512,34 @@ update_mkdocs_yml() {
|
||||
# Function to update service URLs in services.yaml
|
||||
update_services_yaml() {
|
||||
local new_domain=$1
|
||||
|
||||
local local_ip=${2:-"localhost"} # Optional parameter for local IP address
|
||||
|
||||
if [ ! -f "$SERVICES_YAML" ]; then
|
||||
echo "Warning: services.yaml not found at $SERVICES_YAML"
|
||||
return 1
|
||||
fi
|
||||
|
||||
|
||||
echo "Updating service URLs in services.yaml..."
|
||||
|
||||
|
||||
# Create a backup of the services.yaml file
|
||||
local timestamp=$(date +"%Y%m%d_%H%M%S")
|
||||
local backup_file="${SERVICES_YAML}.backup_${timestamp}"
|
||||
cp "$SERVICES_YAML" "$backup_file"
|
||||
echo "Created backup of services.yaml at $backup_file"
|
||||
|
||||
# Define service name to subdomain mapping
|
||||
|
||||
# Load environment variables to get port numbers
|
||||
load_env_vars
|
||||
|
||||
# Define service name to subdomain mapping for Production tab
|
||||
# This approach is URL-agnostic - it doesn't matter what the current URLs are
|
||||
declare -A service_mappings=(
|
||||
declare -A production_mappings=(
|
||||
["Code Server"]="code.$new_domain"
|
||||
["Listmonk"]="listmonk.$new_domain"
|
||||
["NocoDB"]="db.$new_domain"
|
||||
["Map Server"]="map.$new_domain"
|
||||
["Influence"]="influence.$new_domain"
|
||||
["Main Site"]="$new_domain"
|
||||
["MkDocs (Live)"]="docs.$new_domain"
|
||||
["Mini QR"]="qr.$new_domain"
|
||||
["MailHog"]="mail.$new_domain"
|
||||
["n8n"]="n8n.$new_domain"
|
||||
["Gitea"]="git.$new_domain"
|
||||
["Prometheus"]="prometheus.$new_domain"
|
||||
@ -535,41 +548,107 @@ update_services_yaml() {
|
||||
["Gotify"]="gotify.$new_domain"
|
||||
["cAdvisor"]="cadvisor.$new_domain"
|
||||
)
|
||||
|
||||
# Process each service mapping
|
||||
for service_name in "${!service_mappings[@]}"; do
|
||||
local target_url="https://${service_mappings[$service_name]}"
|
||||
|
||||
# Use awk to find and update the href for each specific service
|
||||
# This finds the service by name and updates its href regardless of current URL
|
||||
|
||||
# Define service name to local URL mapping for Local tab
|
||||
declare -A local_mappings=(
|
||||
["Code Server"]="$local_ip:${CODE_SERVER_PORT:-8888}"
|
||||
["NocoDB"]="$local_ip:${NOCODB_PORT:-8090}"
|
||||
["Homepage"]="$local_ip:${HOMEPAGE_PORT:-3010}"
|
||||
["Main Site"]="$local_ip:${MKDOCS_SITE_SERVER_PORT:-4001}"
|
||||
["MkDocs (Live)"]="$local_ip:${MKDOCS_PORT:-4000}"
|
||||
["Mini QR"]="$local_ip:${MINI_QR_PORT:-8089}"
|
||||
["Listmonk"]="$local_ip:${LISTMONK_PORT:-9001}"
|
||||
["MailHog"]="$local_ip:${MAILHOG_WEB_PORT:-8025}"
|
||||
["n8n"]="$local_ip:${N8N_PORT:-5678}"
|
||||
["Gitea"]="$local_ip:${GITEA_WEB_PORT:-3030}"
|
||||
["Prometheus"]="$local_ip:${PROMETHEUS_PORT:-9090}"
|
||||
["Grafana"]="$local_ip:${GRAFANA_PORT:-3001}"
|
||||
["Alertmanager"]="$local_ip:${ALERTMANAGER_PORT:-9093}"
|
||||
["Gotify"]="$local_ip:${GOTIFY_PORT:-8889}"
|
||||
["cAdvisor"]="$local_ip:${CADVISOR_PORT:-8080}"
|
||||
["Node Exporter"]="$local_ip:${NODE_EXPORTER_PORT:-9100}/metrics"
|
||||
["Redis Exporter"]="$local_ip:${REDIS_EXPORTER_PORT:-9121}/metrics"
|
||||
)
|
||||
|
||||
# Update Production URLs
|
||||
echo "Updating Production tab URLs..."
|
||||
for service_name in "${!production_mappings[@]}"; do
|
||||
local target_url="https://${production_mappings[$service_name]}"
|
||||
|
||||
# Use awk to find and update the href for Production services only
|
||||
awk -v service="$service_name" -v new_url="$target_url" '
|
||||
BEGIN { in_service = 0 }
|
||||
|
||||
# Check if we found the service name
|
||||
/- [^:]+:/ {
|
||||
if ($0 ~ ("- " service ":")) {
|
||||
BEGIN {
|
||||
in_production = 0
|
||||
in_service = 0
|
||||
}
|
||||
|
||||
# Track if we are in Production section
|
||||
/^- Production/ { in_production = 1; in_service = 0 }
|
||||
/^- Local/ { in_production = 0; in_service = 0 }
|
||||
|
||||
# Check if we found the service name in Production section
|
||||
in_production && /^ - [^:]+:/ {
|
||||
if ($0 ~ (" - " service ":")) {
|
||||
in_service = 1
|
||||
} else {
|
||||
in_service = 0
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# If we are in the target service and find href line, update it
|
||||
in_service && /href:/ {
|
||||
in_production && in_service && /href:/ {
|
||||
gsub(/href: "[^"]*"/, "href: \"" new_url "\"")
|
||||
}
|
||||
|
||||
|
||||
# Print the line (modified or not)
|
||||
{ print }
|
||||
' "$SERVICES_YAML" > "${SERVICES_YAML}.tmp"
|
||||
|
||||
# Replace the original file with the updated version
|
||||
|
||||
mv "${SERVICES_YAML}.tmp" "$SERVICES_YAML"
|
||||
|
||||
echo " ✓ Updated $service_name -> $target_url"
|
||||
echo " ✓ Production: $service_name -> $target_url"
|
||||
done
|
||||
|
||||
echo "✅ All service URLs updated to use domain: $new_domain"
|
||||
|
||||
# Update Local URLs
|
||||
echo "Updating Local tab URLs..."
|
||||
for service_name in "${!local_mappings[@]}"; do
|
||||
local target_url="http://${local_mappings[$service_name]}"
|
||||
|
||||
# Use awk to find and update the href for Local services only
|
||||
awk -v service="$service_name" -v new_url="$target_url" '
|
||||
BEGIN {
|
||||
in_local = 0
|
||||
in_service = 0
|
||||
}
|
||||
|
||||
# Track if we are in Local section
|
||||
/^- Local/ { in_local = 1; in_service = 0 }
|
||||
/^- Production/ { in_local = 0; in_service = 0 }
|
||||
|
||||
# Check if we found the service name in Local section
|
||||
in_local && /^ - [^:]+:/ {
|
||||
if ($0 ~ (" - " service ":")) {
|
||||
in_service = 1
|
||||
} else {
|
||||
in_service = 0
|
||||
}
|
||||
}
|
||||
|
||||
# If we are in the target service and find href line, update it
|
||||
in_local && in_service && /href:/ {
|
||||
gsub(/href: "[^"]*"/, "href: \"" new_url "\"")
|
||||
}
|
||||
|
||||
# Print the line (modified or not)
|
||||
{ print }
|
||||
' "$SERVICES_YAML" > "${SERVICES_YAML}.tmp"
|
||||
|
||||
mv "${SERVICES_YAML}.tmp" "$SERVICES_YAML"
|
||||
echo " ✓ Local: $service_name -> $target_url"
|
||||
done
|
||||
|
||||
echo "✅ All service URLs updated:"
|
||||
echo " - Production tab: $new_domain"
|
||||
echo " - Local tab: $local_ip"
|
||||
return 0
|
||||
}
|
||||
|
||||
@ -997,6 +1076,8 @@ check_port_conflicts() {
|
||||
"REDIS_EXPORTER_PORT"
|
||||
"ALERTMANAGER_PORT"
|
||||
"GOTIFY_PORT"
|
||||
"MAILHOG_SMTP_PORT"
|
||||
"MAILHOG_WEB_PORT"
|
||||
)
|
||||
|
||||
for var in "${port_vars[@]}"; do
|
||||
@ -1209,6 +1290,7 @@ fi
|
||||
update_env_instance_config "$instance_identifier"
|
||||
|
||||
# Domain configuration
|
||||
echo -e "\n---- Domain Configuration ----"
|
||||
read -p "Enter your domain name (without protocol, e.g., example.com): " domain_name
|
||||
|
||||
if [ -z "$domain_name" ]; then
|
||||
@ -1216,6 +1298,20 @@ if [ -z "$domain_name" ]; then
|
||||
domain_name="changeme.org"
|
||||
fi
|
||||
|
||||
# Local IP configuration for Homepage Local tab
|
||||
echo -e "\n---- Local Network Configuration ----"
|
||||
echo "For the Homepage dashboard, you can configure the Local tab to use a specific"
|
||||
echo "IP address for accessing services on your local network (e.g., Tailscale IP)."
|
||||
echo ""
|
||||
read -p "Enter local IP address [default: localhost]: " local_ip
|
||||
|
||||
if [ -z "$local_ip" ]; then
|
||||
local_ip="localhost"
|
||||
echo "Using default: localhost"
|
||||
else
|
||||
echo "Using local IP: $local_ip"
|
||||
fi
|
||||
|
||||
echo -e "\nUpdating domain settings in .env file..."
|
||||
|
||||
# Update main domain settings
|
||||
@ -1293,7 +1389,7 @@ update_mkdocs_yml "$domain_name"
|
||||
|
||||
# Update service URLs in services.yaml
|
||||
echo -e "\nUpdating service URLs in services.yaml..."
|
||||
update_services_yaml "$domain_name"
|
||||
update_services_yaml "$domain_name" "$local_ip"
|
||||
|
||||
# Update the login URL in main.html
|
||||
echo -e "\nUpdating login URL in main.html..."
|
||||
@ -1380,6 +1476,7 @@ echo -e "\n✅ Configuration completed successfully!"
|
||||
echo "Your .env file has been configured with:"
|
||||
echo "- Instance ID: $instance_identifier"
|
||||
echo "- Domain: $domain_name"
|
||||
echo "- Local IP: $local_ip (for Homepage Local tab)"
|
||||
echo "- Cookie Domain: .$domain_name"
|
||||
echo "- Allowed Origins: https://map.$domain_name,http://localhost:3000"
|
||||
echo "- Map .env updated with domain settings"
|
||||
@ -1390,7 +1487,9 @@ echo "- Grafana Admin Password: Generated (see .env file)"
|
||||
echo "- Gotify Admin Password: Generated (see .env file)"
|
||||
echo "- Centralized services: Redis, Prometheus, Grafana"
|
||||
echo "- Monitoring services: cAdvisor, Node Exporter, Redis Exporter, Alertmanager, Gotify"
|
||||
echo "- Email testing: MailHog"
|
||||
echo "- Tunnel configuration updated at: $TUNNEL_CONFIG_FILE"
|
||||
echo "- Homepage services.yaml configured with Production and Local tabs"
|
||||
echo -e "\nYour .env file is located at: $ENV_FILE"
|
||||
echo "A backup of your original .env file was created before modifications."
|
||||
|
||||
@ -1421,6 +1520,10 @@ echo ""
|
||||
echo " Centralized Services:"
|
||||
echo " - Redis: http://localhost:${REDIS_PORT:-6379}"
|
||||
echo ""
|
||||
echo " Email Testing:"
|
||||
echo " - MailHog Web UI: http://localhost:${MAILHOG_WEB_PORT:-8025}"
|
||||
echo " - MailHog SMTP: localhost:${MAILHOG_SMTP_PORT:-1025}"
|
||||
echo ""
|
||||
echo " Monitoring Services (optional monitoring profile):"
|
||||
echo " - Prometheus: http://localhost:${PROMETHEUS_PORT:-9090}"
|
||||
echo " - Grafana: http://localhost:${GRAFANA_PORT:-3001}"
|
||||
|
||||
@ -413,8 +413,8 @@ services:
|
||||
image: mailhog/mailhog:latest
|
||||
container_name: mailhog-changemaker
|
||||
ports:
|
||||
- "1025:1025" # SMTP server
|
||||
- "8025:8025" # Web UI
|
||||
- "${MAILHOG_SMTP_PORT:-1025}:1025" # SMTP server
|
||||
- "${MAILHOG_WEB_PORT:-8025}:8025" # Web UI
|
||||
restart: unless-stopped
|
||||
networks:
|
||||
- changemaker-lite
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user