-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdev-bootstrap.sh
More file actions
240 lines (206 loc) · 8.05 KB
/
dev-bootstrap.sh
File metadata and controls
240 lines (206 loc) · 8.05 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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
#!/bin/bash
# =============================================================================
# SerialMemory Development Bootstrap (Linux/macOS)
# =============================================================================
# This script sets up a complete local development environment for SerialMemory:
# 1. Starts all Docker services (Postgres, API, Dashboard, Ollama)
# 2. Applies database migrations
# 3. Seeds demo data
# 4. Pulls the embedding model
# 5. Generates a sample API key for testing
# 6. Outputs configuration for Claude Desktop / MCP clients
#
# Usage:
# ./dev-bootstrap.sh # Normal start
# ./dev-bootstrap.sh --reset # Reset database and start fresh
# ./dev-bootstrap.sh --skip-ollama # Skip embedding model download
# =============================================================================
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
CYAN='\033[0;36m'
GRAY='\033[0;90m'
NC='\033[0m' # No Color
# Parse arguments
RESET=false
SKIP_OLLAMA=false
for arg in "$@"; do
case $arg in
--reset)
RESET=true
;;
--skip-ollama)
SKIP_OLLAMA=true
;;
esac
done
echo ""
echo -e "${CYAN}╔════════════════════════════════════════════════════════════════╗${NC}"
echo -e "${CYAN}║ SerialMemory Development Bootstrap (Linux/macOS) ║${NC}"
echo -e "${CYAN}╚════════════════════════════════════════════════════════════════╝${NC}"
echo ""
# -----------------------------------------------------------------------------
# Check prerequisites
# -----------------------------------------------------------------------------
echo -e "${YELLOW}🔍 Checking prerequisites...${NC}"
if ! command -v docker &> /dev/null; then
echo -e "${RED}❌ Docker is not installed or not in PATH${NC}"
echo -e "${GRAY} Please install Docker: https://docs.docker.com/get-docker/${NC}"
exit 1
fi
if ! docker info &> /dev/null; then
echo -e "${RED}❌ Docker is not running${NC}"
echo -e "${GRAY} Please start Docker Desktop or the Docker daemon${NC}"
exit 1
fi
echo -e "${GREEN}✅ Docker is running${NC}"
# -----------------------------------------------------------------------------
# Reset if requested
# -----------------------------------------------------------------------------
if [ "$RESET" = true ]; then
echo ""
echo -e "${YELLOW}🗑️ Resetting environment (removing volumes)...${NC}"
docker compose -f docker-compose.dev.yml down -v 2>/dev/null || true
echo -e "${GREEN}✅ Environment reset complete${NC}"
fi
# -----------------------------------------------------------------------------
# Start services
# -----------------------------------------------------------------------------
echo ""
echo -e "${YELLOW}🚀 Starting Docker services...${NC}"
docker compose -f docker-compose.dev.yml up -d postgres redis
if [ $? -ne 0 ]; then
echo -e "${RED}❌ Failed to start database services${NC}"
exit 1
fi
echo "⏳ Waiting for PostgreSQL to be ready..."
max_attempts=30
attempt=0
while [ $attempt -lt $max_attempts ]; do
attempt=$((attempt + 1))
health=$(docker inspect serialmemory-postgres --format='{{.State.Health.Status}}' 2>/dev/null || echo "unknown")
echo -e "${GRAY} Attempt $attempt/$max_attempts - Status: $health${NC}"
if [ "$health" = "healthy" ]; then
break
fi
sleep 2
done
if [ "$health" != "healthy" ]; then
echo -e "${RED}❌ PostgreSQL failed to start${NC}"
docker logs serialmemory-postgres
exit 1
fi
echo -e "${GREEN}✅ PostgreSQL is ready${NC}"
# Start remaining services
docker compose -f docker-compose.dev.yml up -d
if [ $? -ne 0 ]; then
echo -e "${RED}❌ Failed to start services${NC}"
exit 1
fi
# -----------------------------------------------------------------------------
# Pull Ollama embedding model
# -----------------------------------------------------------------------------
if [ "$SKIP_OLLAMA" = false ]; then
echo ""
echo -e "${YELLOW}📦 Pulling Ollama embedding model (nomic-embed-text)...${NC}"
echo -e "${GRAY} This may take a few minutes on first run...${NC}"
sleep 5 # Wait for Ollama to start
docker exec serialmemory-ollama ollama pull nomic-embed-text 2>&1 | while read line; do
echo -e "${GRAY} $line${NC}"
done
if [ $? -eq 0 ]; then
echo -e "${GREEN}✅ Embedding model ready${NC}"
else
echo -e "${YELLOW}⚠️ Failed to pull embedding model (you can do this manually later)${NC}"
fi
fi
# -----------------------------------------------------------------------------
# Generate sample tokens
# -----------------------------------------------------------------------------
echo ""
echo -e "${YELLOW}🔑 Generating sample credentials...${NC}"
TENANT_ID="00000000-0000-0000-0000-000000000000"
USER_ID="demo-user"
# For self-hosted mode, we use simple API keys (no JWT needed)
API_KEY="sm_dev_$(head -c 16 /dev/urandom | xxd -p | head -c 24)"
echo -e "${GREEN}✅ Credentials generated${NC}"
# -----------------------------------------------------------------------------
# Output configuration
# -----------------------------------------------------------------------------
echo ""
echo -e "${GREEN}╔════════════════════════════════════════════════════════════════╗${NC}"
echo -e "${GREEN}║ Setup Complete! 🎉 ║${NC}"
echo -e "${GREEN}╚════════════════════════════════════════════════════════════════╝${NC}"
echo ""
echo -e "${CYAN}📡 Service URLs:${NC}"
echo " SerialMemory API: http://localhost:5000"
echo " Dashboard API: http://localhost:5001"
echo " PostgreSQL: localhost:5432"
echo " Ollama: http://localhost:11434"
echo " Prometheus: http://localhost:9090"
echo " Grafana: http://localhost:3001 (admin/admin)"
echo ""
echo -e "${CYAN}🔐 Demo Credentials:${NC}"
echo " Tenant ID: $TENANT_ID"
echo " User ID: $USER_ID"
echo " API Key: $API_KEY"
echo ""
echo -e "${CYAN}📋 Claude Desktop Configuration:${NC}"
echo -e "${GRAY} Add this to your claude_desktop_config.json:${NC}"
echo ""
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cat << EOF
{
"mcpServers": {
"serialmemory": {
"command": "dotnet",
"args": ["run", "--project", "${SCRIPT_DIR}/SerialMemory.Mcp"],
"env": {
"POSTGRES_HOST": "localhost",
"POSTGRES_PORT": "5432",
"POSTGRES_USER": "postgres",
"POSTGRES_PASSWORD": "postgres",
"POSTGRES_DB": "contextdb",
"OLLAMA_BASE_URL": "http://localhost:11434",
"OLLAMA_EMBEDDING_MODEL": "nomic-embed-text",
"SERIALMEMORY_MODE": "self-hosted"
}
}
}
}
EOF
echo ""
echo -e "${CYAN}📋 SDK Configuration (.NET):${NC}"
echo ""
cat << EOF
var client = new SerialMemoryClient(new SerialMemoryOptions
{
BaseUrl = "http://localhost:5000",
ApiKey = "$API_KEY",
TenantId = Guid.Parse("$TENANT_ID")
});
EOF
echo ""
echo -e "${CYAN}📋 SDK Configuration (Node.js):${NC}"
echo ""
cat << EOF
const client = new SerialMemoryClient({
baseUrl: 'http://localhost:5000',
apiKey: '$API_KEY',
tenantId: '$TENANT_ID'
});
EOF
echo ""
echo -e "${CYAN}🧪 Test the setup:${NC}"
echo " curl http://localhost:5000/health"
echo ""
echo -e "${CYAN}📚 Next steps:${NC}"
echo " 1. Copy the Claude Desktop config above to your config file"
echo " 2. Restart Claude Desktop to load the MCP server"
echo " 3. Try: 'Search my memory for...' or 'Remember that...'"
echo ""
echo -e "${CYAN}🛑 To stop:${NC}"
echo " docker compose -f docker-compose.dev.yml down"
echo ""