-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·84 lines (61 loc) · 1.7 KB
/
Copy pathdeploy.sh
File metadata and controls
executable file
·84 lines (61 loc) · 1.7 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
#!/bin/bash
set -e
echo "Starting deployment..."
# check if you are on main
if [ "$(git rev-parse --abbrev-ref HEAD)" != "main" ]; then
echo "Error, you need to be on main for this script to work"
exit 1
fi
# ensure you are not forgetting any changes
if ! git diff --quiet; then
echo "Error: You have unstaged local changes. Please commit or stash"
exit 1
fi
ssh aws << 'EOF'
echo "Killing old Node processes..."
sudo kill $(pgrep node)
sudo kill $(pgrep npm)
set -e
# --- BUILD COURSES ---
# pull in the cli, the documentation could need updated
rm -rf ~/oseda-cli
git clone git@github.com:oseda-dev/oseda-cli.git
rm -rf ~/oseda-lib
git clone git@github.com:oseda-dev/oseda-lib.git
cd ~/oseda-lib/courses
echo "Building courses with npx vite..."
for dir in */; do
if [ -f "$dir/package.json" ]; then
echo "Installing and building $dir"
cd "$dir"
npm install
npx vite build
cd ..
else
echo "Skipping $dir - no package.json"
fi
done
cd $HOME
echo "Removing old oseda-core..."
rm -rf oseda-core
echo "Cloning latest oseda-core..."
git clone git@github.com:oseda-dev/oseda-core.git
# link Apache config (force overwrite)
sudo ln -sfn /home/ubuntu/oseda-core/net/oseda.conf /etc/apache2/sites-available/oseda.conf
echo "Enabling site & reloading Apache..."
sudo a2ensite oseda.conf
sudo systemctl reload apache2
# --- START BACKEND (serves SPA + API) ---
cd oseda-core
echo "Installing backend dependencies..."
cd backend
npm install
echo "Installing frontend dependencies & building frontend..."
cd ../frontend
npm install
npm run build
echo "Starting backend..."
cd ../
nohup ./run.sh prod > oseda.log 2>&1 &
EOF
echo "Deployment finished."