Files
usda-vision/scripts/set-host-env.sh
salirezav 8f4225a62e feat: Add dynamic host IP detection for Docker Compose and Supabase config
- Add docker-compose.sh wrapper script that auto-detects host IP
- Update docker-compose.yml to use environment variable substitution
- Update Supabase config.toml files to use HOST_SITE_URL and SUPABASE_API_URL env vars
- Add scripts/get-host-ip.sh for IP detection
- Add scripts/set-host-env.sh for environment setup
- Add scripts/supabase-with-env.sh wrapper for Supabase CLI
- Add documentation for Docker Compose environment setup
- Update README.md with new usage instructions
- Replace hardcoded URLs with dynamic environment variables
2025-12-18 19:57:27 -05:00

34 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
# Script to set HOST_SITE_URL environment variable based on detected host IP
# This should be sourced before running Supabase CLI commands or docker-compose
# Usage: source ./scripts/set-host-env.sh
# Get the script directory
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
# Detect host IP
HOST_IP=$("$SCRIPT_DIR/get-host-ip.sh")
if [ $? -ne 0 ] || [ -z "$HOST_IP" ]; then
echo "Warning: Could not detect host IP, using localhost" >&2
HOST_IP="127.0.0.1"
fi
# Set the environment variable
# Default port is 3000, but can be overridden
PORT="${HOST_PORT:-3000}"
export HOST_SITE_URL="http://${HOST_IP}:${PORT}"
# Only print messages if not being sourced (when run directly)
if [ "${BASH_SOURCE[0]}" = "${0}" ]; then
echo "Set HOST_SITE_URL=$HOST_SITE_URL" >&2
echo "To use this in your current shell, run:" >&2
echo " source $SCRIPT_DIR/set-host-env.sh" >&2
echo "Or export it manually:" >&2
echo " export HOST_SITE_URL=\"$HOST_SITE_URL\"" >&2
else
# Being sourced - just set the variable silently (or with a brief message)
echo "HOST_SITE_URL set to: $HOST_SITE_URL" >&2
fi