-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy-hostinger.sh
More file actions
executable file
·162 lines (145 loc) · 5.04 KB
/
deploy-hostinger.sh
File metadata and controls
executable file
·162 lines (145 loc) · 5.04 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
#!/bin/bash
set -e
# ===========================================
# Excalidraw AI Agent - Hostinger Deployment Script
# ===========================================
# This script automates the deployment process for Hostinger VPS/Cloud hosting.
#
# Usage:
# chmod +x deploy-hostinger.sh
# ./deploy-hostinger.sh
#
# Prerequisites:
# - Docker and Docker Compose installed
# - .env file configured (copy from .env.hostinger.example)
# - SSL certificates in ./ssl/ directory
# ===========================================
echo "=================================="
echo "Excalidraw AI Agent - Hostinger Deployment"
echo "=================================="
echo ""
# ===========================================
# Check if .env exists
# ===========================================
if [ ! -f .env ]; then
echo "❌ Error: .env file not found!"
echo "Copy .env.hostinger.example to .env and configure your values:"
echo " cp .env.hostinger.example .env"
echo " nano .env"
exit 1
fi
# Source environment variables
set -a
source .env
set +a
# ===========================================
# Check required variables
# ===========================================
if [ -z "$HOSTINGER_DOMAIN" ]; then
echo "❌ Error: HOSTINGER_DOMAIN not set in .env"
echo "Edit .env and add your domain name:"
echo " HOSTINGER_DOMAIN=your-domain.com"
exit 1
fi
echo "✓ Domain configured: $HOSTINGER_DOMAIN"
# ===========================================
# Check if Docker is installed
# ===========================================
if ! command -v docker &> /dev/null; then
echo "❌ Error: Docker is not installed!"
echo "Install Docker:"
echo " curl -fsSL https://get.docker.com -o get-docker.sh"
echo " sudo sh get-docker.sh"
exit 1
fi
# ===========================================
# Check if Docker Compose is installed
# ===========================================
if ! command -v docker-compose &> /dev/null; then
echo "❌ Error: Docker Compose is not installed!"
echo "Install Docker Compose:"
echo " sudo curl -L \"https://github.com/docker/compose/releases/latest/download/docker-compose-\$(uname -s)-\$(uname -m)\" -o /usr/local/bin/docker-compose"
echo " sudo chmod +x /usr/local/bin/docker-compose"
exit 1
fi
echo "✓ Docker and Docker Compose are installed"
# ===========================================
# Create SSL directory if it doesn't exist
# ===========================================
mkdir -p ssl
# ===========================================
# Check if SSL certificates exist
# ===========================================
if [ ! -f "ssl/fullchain.pem" ] || [ ! -f "ssl/privkey.pem" ]; then
echo ""
echo "⚠️ Warning: SSL certificates not found in ./ssl/"
echo ""
echo "Generate Let's Encrypt certificates:"
echo " sudo certbot certonly --standalone -d $HOSTINGER_DOMAIN"
echo " sudo cp /etc/letsencrypt/live/$HOSTINGER_DOMAIN/fullchain.pem ssl/"
echo " sudo cp /etc/letsencrypt/live/$HOSTINGER_DOMAIN/privkey.pem ssl/"
echo " sudo chmod 644 ssl/*.pem"
echo ""
read -p "Continue without SSL? (y/N) " -n 1 -r
echo ""
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "Deployment cancelled. Please generate SSL certificates first."
exit 1
fi
echo "⚠️ Proceeding without SSL (not recommended for production)"
else
echo "✓ SSL certificates found"
fi
# ===========================================
# Stop existing containers
# ===========================================
echo ""
echo "🛑 Stopping existing containers..."
docker-compose -f docker-compose.hostinger.yml down 2>/dev/null || true
# ===========================================
# Build and start containers
# ===========================================
echo ""
echo "🔨 Building and starting containers..."
echo ""
docker-compose -f docker-compose.hostinger.yml up -d --build
# ===========================================
# Wait for health check
# ===========================================
echo ""
echo "⏳ Waiting for application to be healthy..."
sleep 10
# ===========================================
# Check status
# ===========================================
echo ""
echo "=================================="
echo "Container Status:"
echo "=================================="
docker-compose -f docker-compose.hostinger.yml ps
# ===========================================
# Display deployment information
# ===========================================
echo ""
echo "=================================="
echo "✅ Deployment complete!"
echo "=================================="
echo ""
echo "Application should be available at:"
echo " 🌐 http://$HOSTINGER_DOMAIN"
echo " 🔒 https://$HOSTINGER_DOMAIN"
echo ""
echo "Health check:"
echo " curl https://$HOSTINGER_DOMAIN/health"
echo ""
echo "View logs:"
echo " docker-compose -f docker-compose.hostinger.yml logs -f"
echo ""
echo "Restart services:"
echo " docker-compose -f docker-compose.hostinger.yml restart"
echo ""
echo "Stop services:"
echo " docker-compose -f docker-compose.hostinger.yml down"
echo ""
echo "=================================="
echo ""