-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·62 lines (52 loc) · 1.86 KB
/
deploy.sh
File metadata and controls
executable file
·62 lines (52 loc) · 1.86 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
#!/bin/bash
set -e
echo "🚀 Starting Deployment Process..."
# 1. Handle local changes to data/config.json
echo "📥 Pulling latest code..."
# Check if there are uncommitted changes
if [[ -n $(git status -s) ]]; then
echo "⚠️ Local changes detected. Preserving configuration..."
# Backup config if it exists and has changes
if [[ -f data/config.json ]]; then
cp data/config.json data/config.json.backup
echo " → Backed up data/config.json"
fi
# Try to reset to remote
if git fetch origin main 2>/dev/null; then
git reset --hard origin/main
else
echo " ⚠️ Could not fetch from remote (network issue). Using local code."
fi
# Restore config backup if exists
if [[ -f data/config.json.backup ]]; then
mv data/config.json.backup data/config.json
echo " → Restored data/config.json"
fi
else
# No local changes, try to pull normally
if ! git pull origin main 2>/dev/null; then
echo " ⚠️ Could not pull from remote (network issue). Using local code."
fi
fi
# 2. Rebuild and Restart containers
echo "🔄 Rebuilding and restarting containers..."
docker-compose down
docker-compose up -d --build
# 3. Cleanup unused images
echo "🧹 Cleaning up unused Docker images..."
docker image prune -f
# 4. Verify deployment
echo "🔍 Verifying deployment..."
if ! docker ps | grep -q "iprotrax"; then
echo "❌ Deployment failed! 'iprotrax' container not found running."
exit 1
fi
if ! docker ps | grep -q "iprotrax-redis"; then
echo "⚠️ Warning: 'iprotrax-redis' container not found running. Real-time features may fail."
fi
echo ""
echo "✅ Deployment complete!"
echo " - App running at: http://localhost:3001"
echo " - Timezone: Asia/Singapore"
echo ""
echo "📜 View logs with: docker-compose logs -f"