-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.sh
More file actions
executable file
·131 lines (115 loc) · 5.02 KB
/
run.sh
File metadata and controls
executable file
·131 lines (115 loc) · 5.02 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#!/usr/bin/env bash
set -e
# ─────────────────────────────────────────────────────────────
# ModelFleet — One-command launcher
# Builds and runs the full platform with Docker Compose.
# Usage: ./run.sh
# ─────────────────────────────────────────────────────────────
BOLD='\033[1m'
GREEN='\033[0;32m'
BLUE='\033[0;34m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
DIM='\033[2m'
NC='\033[0m'
banner() {
echo ""
echo -e "${BLUE}${BOLD}"
echo " ╔══════════════════════════════════════════════╗"
echo " ║ ║"
echo " ║ ModelFleet ║"
echo " ║ Kubernetes ML Model Serving Platform ║"
echo " ║ ║"
echo " ╚══════════════════════════════════════════════╝"
echo -e "${NC}"
}
info() { echo -e " ${BLUE}▸${NC} $1"; }
ok() { echo -e " ${GREEN}✓${NC} $1"; }
warn() { echo -e " ${YELLOW}!${NC} $1"; }
fail() { echo -e " ${RED}✗${NC} $1"; exit 1; }
banner
# ── Check Docker ─────────────────────────────────────────────
info "Checking Docker..."
if ! command -v docker &> /dev/null; then
fail "Docker is not installed. Get it at https://docker.com/products/docker-desktop"
fi
if ! docker info &> /dev/null; then
warn "Docker daemon is not running. Starting Docker Desktop..."
if [[ "$OSTYPE" == "darwin"* ]]; then
open -a Docker
fi
echo -ne " ${DIM}Waiting for Docker"
for i in $(seq 1 30); do
if docker info &> /dev/null; then break; fi
echo -n "."
sleep 2
done
echo -e "${NC}"
docker info &> /dev/null || fail "Could not start Docker. Please start it manually."
fi
ok "Docker is running"
# ── Check Docker Compose ────────────────────────────────────
if docker compose version &> /dev/null; then
COMPOSE="docker compose"
elif command -v docker-compose &> /dev/null; then
COMPOSE="docker-compose"
else
fail "Docker Compose is not available. Update Docker Desktop or install docker-compose."
fi
ok "Docker Compose available"
# ── Build & Start ───────────────────────────────────────────
echo ""
info "Building containers (this may take a few minutes on first run)..."
echo ""
$COMPOSE build
echo ""
info "Starting ModelFleet..."
$COMPOSE up -d
# ── Wait for services ───────────────────────────────────────
echo ""
info "Waiting for services to be ready..."
# Wait for gateway
for i in $(seq 1 60); do
if curl -sf http://localhost:8080/health > /dev/null 2>&1; then
break
fi
sleep 2
done
if ! curl -sf http://localhost:8080/health > /dev/null 2>&1; then
warn "Gateway is taking longer than expected. Check: docker compose logs gateway"
else
ok "Gateway is healthy"
fi
# Check models
for i in $(seq 1 10); do
MODELS=$(curl -sf http://localhost:8080/models 2>/dev/null || echo "")
if echo "$MODELS" | grep -q "sentiment"; then
break
fi
sleep 3
done
ok "Models are registered"
# ── Done ────────────────────────────────────────────────────
echo ""
echo -e "${GREEN}${BOLD} ══════════════════════════════════════════════"
echo -e " ModelFleet is running!"
echo -e " ══════════════════════════════════════════════${NC}"
echo ""
echo -e " ${BOLD}Dashboard:${NC} http://localhost:8080"
echo -e " ${BOLD}API Docs:${NC} http://localhost:8080/docs"
echo -e " ${BOLD}Health:${NC} http://localhost:8080/health"
echo ""
echo -e " ${DIM}Try a prediction:${NC}"
echo -e " ${DIM}curl -X POST http://localhost:8080/models/sentiment/v1/predict \\${NC}"
echo -e " ${DIM} -H 'Content-Type: application/json' \\${NC}"
echo -e " ${DIM} -d '{\"input_data\": {\"text\": \"I love this product!\"}}'${NC}"
echo ""
echo -e " ${DIM}Stop: docker compose down${NC}"
echo -e " ${DIM}Logs: docker compose logs -f${NC}"
echo ""
# ── Open browser ────────────────────────────────────────────
if [[ "$OSTYPE" == "darwin"* ]]; then
open http://localhost:8080
elif command -v xdg-open &> /dev/null; then
xdg-open http://localhost:8080
fi