-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrunalpinemode.sh
More file actions
70 lines (51 loc) · 1.45 KB
/
runalpinemode.sh
File metadata and controls
70 lines (51 loc) · 1.45 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
#!/bin/sh
# run.sh — Alpine-compatible launcher
set -eu
cd "$(dirname "$0")"
MODE="${1:-prod}"
# ---- ensure Python venv support exists (Alpine requirement) ----
if [ ! -d ".venv" ]; then
echo "→ Creating virtualenv .venv"
if ! command -v python3 >/dev/null 2>&1; then
echo "ERROR: python3 is not installed"
exit 1
fi
python3 -m venv .venv
fi
# shellcheck source=/dev/null
. .venv/bin/activate
echo "→ Installing/refreshing dependencies"
pip install --upgrade pip
pip install -r backend/requirements.txt
if [ ! -f "config.yaml" ]; then
echo "⚠ No config.yaml found — using defaults"
fi
get_ip() {
# Alpine-safe IP detection fallback
ip addr show 2>/dev/null | awk '/inet / && $2 !~ /^127/ {print $2}' | cut -d/ -f1 | head -n1
}
case "$MODE" in
dev)
echo "→ Starting backend (dev)"
uvicorn backend.main:app \
--host 0.0.0.0 \
--port 4040 \
--reload &
BACKEND_PID=$!
echo "→ Starting frontend (dev)"
if [ ! -d "frontend/node_modules" ]; then
echo "→ Installing frontend dependencies"
(cd frontend && npm install)
fi
HOST_IP="$(get_ip || echo 127.0.0.1)"
(cd frontend && \
MUSE_FRONTEND_HOST="$HOST_IP" npm run dev) &
FRONTEND_PID=$!
trap 'echo "→ Shutting down..."; kill $BACKEND_PID $FRONTEND_PID 2>/dev/null || true; wait' INT TERM EXIT
wait
;;
prod|*)
echo "→ Starting Muse (production)"
exec python3 -m backend.main
;;
esac