Files
self/app/serve.sh
Timur Gordon be061409af first commit
2025-09-24 05:11:15 +02:00

63 lines
1.8 KiB
Bash
Executable File

#!/bin/bash
# Default values
SERVER_URL="http://localhost:8080"
PORT="8000"
# Parse command line arguments
while [[ $# -gt 0 ]]; do
case $1 in
--server-url)
SERVER_URL="$2"
shift 2
;;
--port)
PORT="$2"
shift 2
;;
-h|--help)
echo "Usage: $0 [OPTIONS]"
echo ""
echo "Options:"
echo " --server-url URL Backend server URL (default: http://localhost:8080)"
echo " --port PORT Frontend port (default: 8000)"
echo " -h, --help Show this help message"
echo ""
echo "Environment variables:"
echo " SELF_SERVER_URL Backend server URL (overrides default)"
echo " SELF_PORT Frontend port (overrides default)"
echo ""
echo "Examples:"
echo " $0 # Use defaults"
echo " $0 --server-url http://localhost:9001 # Custom server URL"
echo " $0 --port 8001 # Custom frontend port"
echo " SELF_SERVER_URL=http://api.example.com $0 # Using env var"
exit 0
;;
*)
echo "Unknown option: $1"
echo "Use --help for usage information"
exit 1
;;
esac
done
# Check for environment variable override
if [ ! -z "$SELF_SERVER_URL" ]; then
SERVER_URL="$SELF_SERVER_URL"
fi
if [ ! -z "$SELF_PORT" ]; then
PORT="$SELF_PORT"
fi
echo "🚀 Starting Self Identity App"
echo "📡 Frontend port: $PORT"
echo "🔗 Backend server: $SERVER_URL"
# Export environment variable for the build
export SERVER_URL="$SERVER_URL"
# Start trunk serve with custom port
trunk serve --port "$PORT"