-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·54 lines (45 loc) · 1.63 KB
/
deploy.sh
File metadata and controls
executable file
·54 lines (45 loc) · 1.63 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
#!/bin/bash
# Automated deployment script
# This script builds, copies frontend to backend, cleans server, and deploys
SERVER_IP="128.173.237.58"
SERVER_USER="sangwonlee"
APP_DIR="counting-app"
echo "🚀 Starting automated deployment..."
echo ""
# Build both frontend and backend
echo "📦 Building frontend and backend..."
npx nx build frontend
npx nx build backend
echo ""
# Copy frontend build into backend dist
echo "📁 Copying frontend build into backend dist..."
cp -r dist/apps/frontend/* apps/backend/dist/
echo "✅ Build complete! Frontend files are now in backend dist folder."
echo ""
# Clean server app directory
echo "🧹 Cleaning server app directory..."
ssh ${SERVER_USER}@${SERVER_IP} "rm -rf ${APP_DIR}/*"
echo ""
# Copy new files to server
echo "📤 Copying new files to server..."
scp -r apps/backend/dist/* ${SERVER_USER}@${SERVER_IP}:${APP_DIR}/
echo ""
# Install dependencies on server
echo "📦 Installing dependencies on server..."
ssh ${SERVER_USER}@${SERVER_IP} "cd ${APP_DIR} && npm install --production && npm install node-fetch@2"
echo ""
echo "✅ Deployment complete!"
echo ""
echo "📝 Now go update the server:"
echo " 1. SSH into server:"
echo " ssh ${SERVER_USER}@${SERVER_IP}"
echo " 2. Go to the app directory:"
echo " cd ${APP_DIR}"
echo " 3. Find the process id of the server (do not forget the \" before node main.js and \" after it):"
echo " ps aux | grep \"node main.js\""
echo " 4. Kill the process:"
echo " kill -9 <process id>"
echo " 5. Start new process:"
echo " nohup node main.js > app.log 2>&1 &"
echo " 6. Go to the website:"
echo " https://count.cs.vt.edu"