-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdocker-setup.sh
executable file
·184 lines (161 loc) · 5.6 KB
/
docker-setup.sh
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
#!/bin/bash
# Colors for better output
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m' # No Color
echo -e "${GREEN}Bunnyshell MCP Server Docker Setup${NC}"
echo "====================================\n"
echo -e "${YELLOW}This setup uses the official bunnyshell/cli Alpine Linux-based image.${NC}\n"
# Check if Docker is installed
if ! command -v docker &> /dev/null; then
echo -e "${RED}Docker is not installed. Please install Docker and try again.${NC}"
exit 1
fi
# Check Docker version
DOCKER_VERSION=$(docker --version | cut -d' ' -f3 | cut -d'.' -f1)
if [ "$DOCKER_VERSION" -lt 20 ]; then
echo -e "${RED}Docker version 20+ is required. Current version: $DOCKER_VERSION${NC}"
exit 1
fi
# Check if Docker Compose is installed
if ! command -v docker-compose &> /dev/null; then
echo -e "${RED}Docker Compose is not installed. Please install Docker Compose and try again.${NC}"
exit 1
fi
# Create Docker Compose file if it doesn't exist
if [ ! -f "docker-compose.yml" ]; then
echo -e "${YELLOW}Creating docker-compose.yml...${NC}"
cat > docker-compose.yml << EOF
version: '3.8'
services:
bns-mcp-server:
build: .
container_name: bns-mcp-server
volumes:
- .:/app
environment:
- NODE_ENV=production
restart: unless-stopped
EOF
fi
# Create Dockerfile if it doesn't exist
if [ ! -f "Dockerfile" ]; then
echo -e "${YELLOW}Creating Dockerfile...${NC}"
cat > Dockerfile << EOF
FROM node:18-alpine
WORKDIR /app
# Install Bunnyshell CLI
RUN apk add --no-cache curl bash && \
curl -fsSL https://raw.githubusercontent.com/bunnyshell/cli/main/install.sh | bash
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build
CMD ["node", "dist/index.js"]
EOF
fi
# Optional: Ask for API token
read -p "Would you like to add your Bunnyshell API token to the Docker configuration? (y/n): " ADD_TOKEN
if [[ "$ADD_TOKEN" =~ ^[Yy]$ ]]; then
read -p "Enter your Bunnyshell API token: " API_TOKEN
if [ ! -z "$API_TOKEN" ]; then
# Add the token to the docker-compose.yml file
echo -e "${YELLOW}Adding API token to docker-compose.yml...${NC}"
sed -i'' -e 's/- NODE_ENV=production/- NODE_ENV=production\n - BNS_API_KEY='"$API_TOKEN"'/' docker-compose.yml
echo -e "${GREEN}API token added to docker-compose.yml.${NC}"
else
echo -e "${YELLOW}No token provided. You'll need to provide it during conversations with Claude.${NC}"
fi
fi
# Build and start the container
echo -e "${YELLOW}Building and starting the Docker container...${NC}"
docker-compose up -d --build
# Check if container is running
if [ $? -eq 0 ] && [ "$(docker ps -q -f name=bns-mcp-server)" ]; then
echo -e "\n${GREEN}Container is running successfully!${NC}"
# Set up Claude Desktop config
CLAUDE_CONFIG_DIR="$HOME/.claude-dev"
CLAUDE_CONFIG_FILE="$CLAUDE_CONFIG_DIR/config.json"
if [ ! -d "$CLAUDE_CONFIG_DIR" ]; then
echo -e "\n${YELLOW}Creating Claude Desktop config directory...${NC}"
mkdir -p "$CLAUDE_CONFIG_DIR"
fi
# Create or update Claude config with or without token
if [[ "$ADD_TOKEN" =~ ^[Yy]$ ]] && [ ! -z "$API_TOKEN" ]; then
if [ ! -f "$CLAUDE_CONFIG_FILE" ]; then
echo -e "\n${YELLOW}Creating Claude Desktop config file with API token...${NC}"
cat > "$CLAUDE_CONFIG_FILE" << EOF
{
"mcpServers": {
"bunnyshell-mcp": {
"command": "docker",
"args": ["exec", "-i", "bns-mcp-server", "node", "dist/index.js"],
"env": {
"BNS_API_KEY": "$API_TOKEN"
}
}
}
}
EOF
else
echo -e "\n${YELLOW}Claude Desktop config file already exists. Please add the following configuration manually:${NC}"
echo ""
echo "{
\"mcpServers\": {
\"bunnyshell-mcp\": {
\"command\": \"docker\",
\"args\": [\"exec\", \"-i\", \"bns-mcp-server\", \"node\", \"dist/index.js\"],
\"env\": {
\"BNS_API_KEY\": \"$API_TOKEN\"
}
}
}
}"
fi
else
if [ ! -f "$CLAUDE_CONFIG_FILE" ]; then
echo -e "\n${YELLOW}Creating Claude Desktop config file...${NC}"
cat > "$CLAUDE_CONFIG_FILE" << EOF
{
"mcpServers": {
"bunnyshell-mcp": {
"command": "docker",
"args": ["exec", "-i", "bns-mcp-server", "node", "dist/index.js"]
}
}
}
EOF
else
echo -e "\n${YELLOW}Claude Desktop config file already exists. Please add the following configuration manually:${NC}"
echo ""
echo "{
\"mcpServers\": {
\"bunnyshell-mcp\": {
\"command\": \"docker\",
\"args\": [\"exec\", \"-i\", \"bns-mcp-server\", \"node\", \"dist/index.js\"]
}
}
}"
fi
fi
echo -e "\n${GREEN}Setup complete!${NC}"
echo -e "Now you need to:"
echo -e "1. Start or restart Claude Desktop"
echo -e "2. Start a new conversation with Claude"
echo -e "3. Click '+' to add an attachment and select 'Connect to MCP server'"
echo -e "4. Choose 'bunnyshell-mcp' from the list of servers"
if [[ ! "$ADD_TOKEN" =~ ^[Yy]$ ]] || [ -z "$API_TOKEN" ]; then
echo -e "5. Set your Bunnyshell API token using: token: YOUR_API_TOKEN"
fi
echo -e "6. Start managing your Bunnyshell resources!\n"
echo -e "Example commands you can try:"
echo -e "- List your organizations"
echo -e "- List projects in an organization"
echo -e "- Create a new environment"
echo -e "- Deploy a component\n"
echo -e "For more details, see the ${YELLOW}README.md${NC} file."
else
echo -e "\n${RED}Failed to start container. Check the logs with:${NC} docker-compose logs"
exit 1
fi