-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
Β·226 lines (191 loc) Β· 7.89 KB
/
install.sh
File metadata and controls
executable file
Β·226 lines (191 loc) Β· 7.89 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
#!/bin/bash
# BlockBot Installation Script
# This script sets up BlockBot for local development or production deployment
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
echo -e "${BLUE}"
echo "ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ"
echo "β β"
echo "β βββββββ βββ βββββββ ββββββββββ ββββββββββ βββββββ βββββββββ β"
echo "β βββββββββββ ββββββββββββββββββββ ββββββββββββββββββββββββββββββ β"
echo "β βββββββββββ βββ ββββββ βββββββ βββββββββββ βββ βββ β"
echo "β βββββββββββ βββ ββββββ βββββββ βββββββββββ βββ βββ β"
echo "β ββββββββββββββββββββββββββββββββββββ ββββββββββββββββββββ βββ β"
echo "β βββββββ ββββββββ βββββββ ββββββββββ ββββββββββ βββββββ βββ β"
echo "β β"
echo "β AI-Powered Project Management Agent β"
echo "β β"
echo "ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ"
echo -e "${NC}"
# Check prerequisites
echo -e "${YELLOW}Checking prerequisites...${NC}"
# Check Docker
if ! command -v docker &> /dev/null; then
echo -e "${RED}Error: Docker is not installed.${NC}"
echo "Please install Docker: https://docs.docker.com/get-docker/"
exit 1
fi
echo -e "${GREEN}β Docker installed${NC}"
# Check Docker Compose
if ! docker compose version &> /dev/null; then
echo -e "${RED}Error: Docker Compose is not installed.${NC}"
echo "Please install Docker Compose: https://docs.docker.com/compose/install/"
exit 1
fi
echo -e "${GREEN}β Docker Compose installed${NC}"
# Function to generate random string
generate_secret() {
openssl rand -base64 32 | tr -d '/+=' | head -c 32
}
# Check if .env exists
if [ -f ".env" ]; then
echo -e "${YELLOW}Found existing .env file.${NC}"
read -p "Do you want to keep it? (y/n) " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
mv .env .env.backup
echo -e "${YELLOW}Backed up to .env.backup${NC}"
CREATE_ENV=true
else
CREATE_ENV=false
fi
else
CREATE_ENV=true
fi
# Create .env file if needed
if [ "$CREATE_ENV" = true ]; then
echo -e "${YELLOW}Creating .env file...${NC}"
# Generate secrets
JWT_SECRET=$(generate_secret)
JWT_REFRESH_SECRET=$(generate_secret)
POSTGRES_PASSWORD=$(generate_secret)
LITELLM_MASTER_KEY=$(generate_secret)
LITELLM_SALT_KEY=$(generate_secret)
# Ask for OpenAI API key
echo ""
echo -e "${BLUE}BlockBot requires an LLM API key to function.${NC}"
echo "Get your OpenAI API key from: https://platform.openai.com/api-keys"
echo ""
read -p "Enter your OpenAI API key (sk-...): " OPENAI_API_KEY
if [[ ! $OPENAI_API_KEY =~ ^sk- ]]; then
echo -e "${RED}Warning: API key doesn't look valid (should start with 'sk-')${NC}"
read -p "Continue anyway? (y/n) " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
exit 1
fi
fi
# Optional: Resend API key
echo ""
echo -e "${BLUE}Email sending (optional - for invitations and magic links)${NC}"
echo "Get your Resend API key from: https://resend.com"
read -p "Enter your Resend API key (press Enter to skip): " RESEND_API_KEY
RESEND_API_KEY=${RESEND_API_KEY:-re_test_placeholder}
# Create .env file
cat > .env << EOF
# BlockBot Configuration
# Generated by install.sh on $(date)
# Database
DATABASE_URL=postgres://blockbot:${POSTGRES_PASSWORD}@localhost:5433/blockbot
POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
# Redis
REDIS_URL=redis://localhost:6379
# JWT Authentication (auto-generated secrets)
JWT_SECRET=${JWT_SECRET}
JWT_REFRESH_SECRET=${JWT_REFRESH_SECRET}
# Email (Resend)
RESEND_API_KEY=${RESEND_API_KEY}
# Server
NODE_ENV=development
PORT=3000
CORS_ORIGIN=http://localhost:3001
APP_URL=http://localhost:3000
# LiteLLM (AI/LLM Proxy)
LITELLM_URL=http://localhost:4010
LITELLM_API_KEY=sk-dev-key
LITELLM_MASTER_KEY=${LITELLM_MASTER_KEY}
LITELLM_SALT_KEY=${LITELLM_SALT_KEY}
# LLM Provider
OPENAI_API_KEY=${OPENAI_API_KEY}
# Optional: Telegram Bot
# TELEGRAM_BOT_TOKEN=
# Optional: WhatsApp Cloud API
# WHATSAPP_ACCESS_TOKEN=
# WHATSAPP_PHONE_NUMBER_ID=
# WHATSAPP_VERIFY_TOKEN=
# WHATSAPP_APP_SECRET=
# Optional: S3 Storage (for file uploads)
# S3_ACCESS_KEY_ID=
# S3_SECRET_ACCESS_KEY=
# S3_BUCKET=
# S3_ENDPOINT=
# Optional: Linear Integration
# LINEAR_WEBHOOK_SECRET=
# Optional: GitHub App (for coding agent)
# GITHUB_APP_ID=
# GITHUB_APP_PRIVATE_KEY=
EOF
echo -e "${GREEN}β Created .env file${NC}"
fi
# Start services
echo ""
echo -e "${YELLOW}Starting BlockBot services...${NC}"
echo "This may take a few minutes on first run (building images)..."
echo ""
docker compose up -d --build
# Wait for services to be healthy
echo ""
echo -e "${YELLOW}Waiting for services to be ready...${NC}"
# Wait for API to be healthy
MAX_ATTEMPTS=30
ATTEMPT=0
while [ $ATTEMPT -lt $MAX_ATTEMPTS ]; do
if curl -s http://localhost:3000/health | grep -q "ok"; then
break
fi
ATTEMPT=$((ATTEMPT + 1))
echo -n "."
sleep 2
done
echo ""
if [ $ATTEMPT -eq $MAX_ATTEMPTS ]; then
echo -e "${RED}Warning: API may not be fully ready yet.${NC}"
echo "Check logs with: docker compose logs api"
else
echo -e "${GREEN}β API is ready${NC}"
fi
# Run migrations
echo ""
echo -e "${YELLOW}Running database migrations...${NC}"
docker compose exec api bun run db:migrate || {
echo -e "${YELLOW}Note: If migrations fail, they may have already been run.${NC}"
}
echo ""
echo -e "${GREEN}ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ${NC}"
echo -e "${GREEN}β Installation Complete! β${NC}"
echo -e "${GREEN}ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ${NC}"
echo ""
echo -e "BlockBot is now running!"
echo ""
echo -e " ${BLUE}Web Dashboard:${NC} http://localhost:3001"
echo -e " ${BLUE}API:${NC} http://localhost:3000"
echo -e " ${BLUE}API Docs:${NC} http://localhost:3000/docs"
echo -e " ${BLUE}Health Check:${NC} http://localhost:3000/health"
echo ""
echo -e "Useful commands:"
echo -e " ${YELLOW}docker compose logs -f${NC} - View all logs"
echo -e " ${YELLOW}docker compose logs api${NC} - View API logs"
echo -e " ${YELLOW}docker compose down${NC} - Stop all services"
echo -e " ${YELLOW}docker compose up -d${NC} - Start services"
echo -e " ${YELLOW}docker compose restart${NC} - Restart services"
echo ""
echo -e "${BLUE}Get started:${NC}"
echo "1. Open http://localhost:3001 in your browser"
echo "2. Register a new account"
echo "3. Create your first project"
echo ""