-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathdocker-push.sh
More file actions
executable file
·179 lines (145 loc) · 3.9 KB
/
Copy pathdocker-push.sh
File metadata and controls
executable file
·179 lines (145 loc) · 3.9 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
#!/bin/bash
# Docker Registry Push Script for Crawl4AI MCP Server
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
# Configuration
DOCKER_REPO="uysalsadi/crawl4ai-mcp-server"
VERSION="v1.0.0"
# Helper function for logging
log() {
echo -e "${BLUE}[docker-push]${NC} $1"
}
error() {
echo -e "${RED}[ERROR]${NC} $1" >&2
}
success() {
echo -e "${GREEN}[SUCCESS]${NC} $1"
}
warn() {
echo -e "${YELLOW}[WARN]${NC} $1"
}
# Show usage
show_usage() {
cat << EOF
Docker Registry Push Script for Crawl4AI MCP Server
Usage: $0 <command>
Commands:
login Login to Docker Hub
build Build and tag Docker image
push Push image to Docker Hub
test Test the pushed image
all Do everything (build, push, test)
help Show this help message
Examples:
$0 login # Login to Docker Hub first
$0 all # Build, push, and test everything
Before running:
1. Make sure you have a Docker Hub account
2. Run: $0 login
3. Run: $0 all
EOF
}
# Docker login
docker_login() {
log "Logging in to Docker Hub..."
log "Please enter your Docker Hub credentials when prompted"
docker login
success "Docker login successful!"
}
# Build and tag image
build_image() {
log "Building Docker image..."
# Build using the simplified Dockerfile
docker build -f Dockerfile.simple \
-t ${DOCKER_REPO}:latest \
-t ${DOCKER_REPO}:${VERSION} \
.
success "Docker image built and tagged successfully!"
log "Tags created:"
log " - ${DOCKER_REPO}:latest"
log " - ${DOCKER_REPO}:${VERSION}"
}
# Push to registry
push_image() {
log "Pushing image to Docker Hub..."
# Push both tags
docker push ${DOCKER_REPO}:latest
docker push ${DOCKER_REPO}:${VERSION}
success "Docker image pushed successfully!"
log "Available at:"
log " - docker pull ${DOCKER_REPO}:latest"
log " - docker pull ${DOCKER_REPO}:${VERSION}"
}
# Test the pushed image
test_image() {
log "Testing the pushed image..."
# Pull and test the latest image
docker pull ${DOCKER_REPO}:latest
# Test basic functionality
log "Testing MCP server initialization..."
init_request='{"jsonrpc": "2.0", "id": 1, "method": "initialize", "params": {"protocolVersion": "2024-11-05", "capabilities": {}, "clientInfo": {"name": "test", "version": "1.0"}}}'
response=$(echo "$init_request" | docker run --rm -i ${DOCKER_REPO}:latest | head -1)
if echo "$response" | grep -q '"name":"crawl4ai-mcp"'; then
success "✅ Pushed image works correctly!"
log "Response: $response"
else
error "❌ Pushed image test failed"
log "Response: $response"
return 1
fi
}
# Do everything
do_all() {
log "Building, pushing, and testing Docker image..."
build_image
push_image
test_image
success "🎉 All operations completed successfully!"
cat << EOF
🐳 Your Docker image is now available publicly!
📦 To use it:
docker pull ${DOCKER_REPO}:latest
docker run --rm -i ${DOCKER_REPO}:latest
🔧 For MCP integration, use the provided config files:
- .mcp.json (project-scoped)
- claude-desktop-config.json (global Claude Desktop)
EOF
}
# Main execution
main() {
if [ $# -eq 0 ]; then
show_usage
exit 1
fi
case "$1" in
"login")
docker_login
;;
"build")
build_image
;;
"push")
push_image
;;
"test")
test_image
;;
"all")
do_all
;;
"help"|"-h"|"--help")
show_usage
;;
*)
error "Unknown command: $1"
show_usage
exit 1
;;
esac
}
main "$@"