-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·70 lines (58 loc) · 1.93 KB
/
Copy pathdeploy.sh
File metadata and controls
executable file
·70 lines (58 loc) · 1.93 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
#!/bin/bash
set -e
# Load environment variables
if [ ! -f .env ]; then
echo "Error: .env file not found in the project root"
exit 1
fi
source .env
if [ -z "$DOMAIN" ] || [ -z "$EMAIL" ]; then
echo "Error: DOMAIN and EMAIL must be set in .env file"
exit 1
fi
echo "=========================================="
echo "Deploying Leaf Classifier Application"
echo "Domain: $DOMAIN"
echo "Email: $EMAIL"
echo "=========================================="
# Create certbot directories if they don't exist
mkdir -p certbot/conf certbot/www
# Build and start all services (without certbot_init)
echo ""
echo "Building and starting services..."
sudo docker compose -f docker-compose.prod.yml up -d --build
# Wait for frontend to be ready
echo ""
echo "Waiting for frontend to be ready..."
sleep 10
# Check if certificate already exists
CERT_PATH="./certbot/conf/live/$DOMAIN/fullchain.pem"
if [ -f "$CERT_PATH" ]; then
echo ""
echo "SSL certificate already exists. Skipping certificate generation."
echo "If you need to regenerate, delete: $CERT_PATH"
else
echo ""
echo "Requesting SSL certificate from Let's Encrypt..."
sudo docker compose -f docker-compose.prod.yml --profile init run --rm certbot_init
# Wait a moment for certificates to be written
sleep 5
# Reload nginx to pick up SSL configuration
echo ""
echo "Reloading nginx to enable SSL..."
sudo docker compose -f docker-compose.prod.yml exec frontend nginx -s reload || true
fi
echo ""
echo "=========================================="
echo "Deployment complete!"
echo ""
echo "Your application is now available at:"
echo " Frontend: https://$DOMAIN"
echo " API: https://$DOMAIN/api/v1"
echo ""
echo "To view logs:"
echo " sudo docker compose -f docker-compose.prod.yml logs -f"
echo ""
echo "To check certificate status:"
echo " sudo docker compose -f docker-compose.prod.yml logs certbot"
echo "=========================================="