-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdev.sh
More file actions
executable file
·85 lines (75 loc) · 2.41 KB
/
Copy pathdev.sh
File metadata and controls
executable file
·85 lines (75 loc) · 2.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/bin/bash
# BGE Development Server Startup Script
# Starts the local development environment using Docker Compose
#
# Usage:
# ./dev.sh # Auto-detect mode (GitHub OAuth if creds present, else DevAuth)
# ./dev.sh --dev-auth # Force DevAuth mode (password-less login)
# ./dev.sh --github # Require GitHub OAuth credentials
set -e
MODE="auto"
# Parse arguments
while [[ $# -gt 0 ]]; do
case $1 in
--dev-auth)
MODE="devauth"
shift
;;
--github)
MODE="github"
shift
;;
*)
echo "Unknown option: $1"
echo "Usage: $0 [--dev-auth | --github]"
exit 1
;;
esac
done
# Navigate to src directory (works from anywhere)
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
SRC_DIR="$SCRIPT_DIR/src"
if [ ! -d "$SRC_DIR" ]; then
echo "❌ Error: src/ directory not found at $SRC_DIR"
exit 1
fi
cd "$SRC_DIR"
# Determine which mode to use
if [ "$MODE" = "auto" ]; then
if [ -n "$GITHUB_CLIENT_ID" ] && [ -n "$GITHUB_CLIENT_SECRET" ]; then
MODE="github"
else
MODE="devauth"
fi
fi
# Find the correct docker-compose command (docker compose vs docker-compose)
if command -v docker-compose &> /dev/null; then
DOCKER_COMPOSE_CMD="docker-compose"
elif command -v docker &> /dev/null && docker compose version &> /dev/null; then
DOCKER_COMPOSE_CMD="docker compose"
else
echo "❌ Error: docker-compose is not installed"
echo "Install Docker Desktop or the Docker CLI with compose plugin"
exit 1
fi
# Start server based on mode
if [ "$MODE" = "devauth" ]; then
echo "🚀 Starting BGE dev server with DevAuth (password-less login)..."
export Bge__DevAuth=true
# DevAuth requires placeholder GitHub creds to pass startup validation
export GITHUB_CLIENT_ID="${GITHUB_CLIENT_ID:-dev-placeholder}"
export GITHUB_CLIENT_SECRET="${GITHUB_CLIENT_SECRET:-dev-placeholder}"
$DOCKER_COMPOSE_CMD up --build
else
# GitHub OAuth mode
if [ -z "$GITHUB_CLIENT_ID" ]; then
echo "❌ Error: GITHUB_CLIENT_ID not set. Either set it or use --dev-auth flag"
exit 1
fi
if [ -z "$GITHUB_CLIENT_SECRET" ]; then
echo "❌ Error: GITHUB_CLIENT_SECRET not set. Either set it or use --dev-auth flag"
exit 1
fi
echo "🚀 Starting BGE dev server with GitHub OAuth..."
$DOCKER_COMPOSE_CMD up --build
fi