-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·85 lines (69 loc) · 2.62 KB
/
deploy.sh
File metadata and controls
executable file
·85 lines (69 loc) · 2.62 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
#!/bin/bash
# Quick deployment script for Browser Automation Service
# Usage: ./deploy.sh [server_ip]
set -e
SERVER_IP=${1:-"10.0.0.2"}
echo "🚀 Deploying Browser Automation Service for server: $SERVER_IP"
# Check if we're in the right directory
if [ ! -f "package.json" ] || [ ! -f "docker-compose.yml" ]; then
echo "❌ Error: Run this script from the project root directory"
exit 1
fi
# Check if Docker is available
if ! command -v docker &> /dev/null; then
echo "❌ Error: Docker is not installed or not in PATH"
exit 1
fi
if ! command -v docker-compose &> /dev/null && ! docker compose version &> /dev/null; then
echo "❌ Error: Docker Compose is not installed or not in PATH"
exit 1
fi
echo "📋 Setting up production environment..."
# Create production environment file if it doesn't exist
if [ ! -f ".env.production" ]; then
echo "📝 Creating .env.production from template..."
cp .env.production.example .env.production
# Update server IP in the production environment
sed -i "s/10\.0\.0\.2/$SERVER_IP/g" .env.production
echo "✅ Updated ALLOWED_ORIGINS for server IP: $SERVER_IP"
echo "⚠️ Please review .env.production for any additional configuration needed"
fi
# Create logs directory
mkdir -p logs
echo "🐳 Building and starting Docker containers..."
# Stop existing containers
docker-compose down 2>/dev/null || true
# Build and start the service
docker-compose up -d browser-automation-service
# Wait a moment for the service to start
echo "⏳ Waiting for service to start..."
sleep 10
# Check if service is healthy
echo "🔍 Checking service health..."
if curl -s "http://localhost:3010/health" > /dev/null; then
echo "✅ Service is running and healthy!"
echo ""
echo "🌐 Service URLs:"
echo " Health check: http://$SERVER_IP:3010/health"
echo " API base: http://$SERVER_IP:3010/api"
echo " WebSocket: ws://$SERVER_IP:3010/ws"
echo ""
echo "📱 Browser Extension Configuration:"
echo " Server URL: http://$SERVER_IP:3010"
echo ""
echo "🔧 Next steps:"
echo " 1. Test the health endpoint: curl http://$SERVER_IP:3010/health"
echo " 2. Build browser extension: ./build.sh"
echo " 3. Configure firewall to allow port 3010"
echo " 4. Distribute extension to users"
echo ""
echo "📊 Monitor with:"
echo " docker-compose ps"
echo " docker-compose logs browser-automation-service"
else
echo "❌ Service health check failed!"
echo "📋 Check logs:"
echo " docker-compose logs browser-automation-service"
exit 1
fi
echo "🎉 Deployment completed successfully!"