Update .gitignore and refactor docker-compose.sh for improved host IP detection

- Added .host-ip to .gitignore to prevent tracking of host IP configurations.
- Enhanced docker-compose.sh to prioritize HOST_IP environment variable, fallback to .host-ip file, and finally auto-detect the host IP, improving robustness in various environments.
- Updated documentation to reflect changes in Supabase migration paths and removed references to deprecated management-dashboard-web-app directory.
This commit is contained in:
salirezav
2026-02-09 13:21:08 -05:00
parent 6a8f238bee
commit 38a7846e7b
31 changed files with 56 additions and 6234 deletions

View File

@@ -42,10 +42,32 @@ get_ip_from_hostname() {
fi
}
# Method 5: Prefer 100.x.x.x (e.g. Tailscale) when present on the host
get_ip_prefer_100() {
local ip=""
if command -v ip >/dev/null 2>&1; then
# Third column is ADDR/CIDR (e.g. 100.93.40.84/32); extract IPv4 and prefer 100.x
ip=$(ip -br addr show 2>/dev/null | awk '{print $3}' | grep -oE '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+' | grep -E '^100\.' | head -1)
fi
if [ -z "$ip" ] && command -v hostname >/dev/null 2>&1; then
ip=$(hostname -I 2>/dev/null | tr ' ' '\n' | grep -E '^100\.' | head -1)
fi
echo "$ip"
}
# Main logic: Try methods in order of reliability
detect_host_ip() {
local ip=""
# When on the host (not in Docker), prefer 100.x.x.x (Tailscale) so the dashboard is reachable via that IP
if [ ! -f /.dockerenv ] && [ -z "${DOCKER_CONTAINER:-}" ]; then
ip=$(get_ip_prefer_100)
if [ -n "$ip" ] && [ "$ip" != "127.0.0.1" ]; then
echo "$ip"
return 0
fi
fi
# If running inside Docker, try gateway method first
if [ -f /.dockerenv ] || [ -n "${DOCKER_CONTAINER:-}" ]; then
ip=$(get_ip_from_gateway)
@@ -53,7 +75,7 @@ detect_host_ip() {
echo "$ip"
return 0
fi
# Try host.docker.internal
ip=$(get_ip_from_host_docker_internal)
if [ -n "$ip" ] && [ "$ip" != "127.0.0.1" ]; then
@@ -61,21 +83,21 @@ detect_host_ip() {
return 0
fi
fi
# Try interface method (works on host machine)
ip=$(get_ip_from_interface)
if [ -n "$ip" ] && [ "$ip" != "127.0.0.1" ]; then
echo "$ip"
return 0
fi
# Try hostname method
ip=$(get_ip_from_hostname)
if [ -n "$ip" ] && [ "$ip" != "127.0.0.1" ]; then
echo "$ip"
return 0
fi
# Fallback: return localhost (not ideal but better than nothing)
echo "127.0.0.1"
return 1