-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·139 lines (109 loc) · 3.56 KB
/
deploy.sh
File metadata and controls
executable file
·139 lines (109 loc) · 3.56 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
#!/bin/bash
# Chronicle Deployment Script
# Builds and deploys Chronicle to ritualstack.io
set -e # Exit on any error
# Configuration
SERVER_USER="xdrabbit_ritualstack"
SERVER_HOST="ssh.nyc1.nearlyfreespeech.net"
SERVER_PATH="/home/protected" # NFSN structure
SITE_PATH="/home/public" # Where website files go
SUBDOMAIN="chronicle" # chronicle.ritualstack.io
# Colors for output
GREEN='\033[0;32m'
BLUE='\033[0;34m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
echo -e "${BLUE}🚀 Chronicle Deployment Script${NC}"
echo "================================"
# Step 1: Build Frontend
echo -e "\n${GREEN}Step 1: Building Frontend...${NC}"
cd frontend
echo "Installing dependencies..."
npm install
echo "Building production bundle..."
npm run build
if [ ! -d "dist" ]; then
echo -e "${YELLOW}Error: Frontend build failed - dist folder not found${NC}"
exit 1
fi
echo -e "${GREEN}✓ Frontend built successfully${NC}"
cd ..
# Step 2: Prepare Backend
echo -e "\n${GREEN}Step 2: Preparing Backend...${NC}"
cd backend
# Check if requirements.txt exists
if [ ! -f "requirements.txt" ]; then
echo -e "${YELLOW}Error: requirements.txt not found${NC}"
exit 1
fi
echo -e "${GREEN}✓ Backend ready${NC}"
cd ..
# Step 3: Package for deployment
echo -e "\n${GREEN}Step 3: Creating deployment package...${NC}"
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
PACKAGE_NAME="chronicle-${TIMESTAMP}.tar.gz"
tar -czf "$PACKAGE_NAME" \
--exclude='node_modules' \
--exclude='__pycache__' \
--exclude='.venv' \
--exclude='.git' \
--exclude='*.pyc' \
--exclude='frontend/dist/test_audio.wav' \
frontend/dist \
backend
echo -e "${GREEN}✓ Package created: $PACKAGE_NAME${NC}"
# Step 4: Upload to server
echo -e "\n${GREEN}Step 4: Uploading to ${SERVER_HOST}...${NC}"
echo "This will upload to: ${SERVER_USER}@${SERVER_HOST}:${SERVER_PATH}/"
read -p "Continue? (y/n) " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "Deployment cancelled"
exit 1
fi
# Create directory on server if it doesn't exist
ssh ${SERVER_USER}@${SERVER_HOST} "mkdir -p ${SERVER_PATH}"
# Upload package
scp "$PACKAGE_NAME" ${SERVER_USER}@${SERVER_HOST}:${SERVER_PATH}/
echo -e "${GREEN}✓ Upload complete${NC}"
# Step 5: Deploy on server
echo -e "\n${GREEN}Step 5: Deploying on server...${NC}"
ssh ${SERVER_USER}@${SERVER_HOST} << EOF
set -e
cd ${SERVER_PATH}
echo "Extracting package..."
tar -xzf ${PACKAGE_NAME}
echo "Setting up backend..."
cd backend
# Create virtual environment if it doesn't exist
if [ ! -d ".venv" ]; then
python3 -m venv .venv
fi
source .venv/bin/activate
pip install -r requirements.txt
echo "Backend setup complete"
# Check if systemd service exists
if [ -f "/etc/systemd/system/chronicle.service" ]; then
echo "Restarting Chronicle service..."
sudo systemctl restart chronicle
else
echo "Note: systemd service not found. You'll need to set it up manually."
echo "See DEPLOYMENT.md for instructions."
fi
EOF
echo -e "\n${GREEN}✓ Deployment complete!${NC}"
echo ""
echo "Next steps:"
echo "1. Configure Nginx for ${SUBDOMAIN}.${SERVER_HOST}"
echo "2. Set up SSL with: sudo certbot --nginx -d ${SUBDOMAIN}.${SERVER_HOST}"
echo "3. Visit https://${SUBDOMAIN}.${SERVER_HOST}"
echo ""
echo "See DEPLOYMENT.md for detailed configuration instructions."
# Cleanup
read -p "Delete deployment package locally? (y/n) " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
rm "$PACKAGE_NAME"
echo "Package deleted"
fi
echo -e "\n${BLUE}Deployment script finished!${NC}"