-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.sh
More file actions
71 lines (60 loc) · 2.53 KB
/
deploy.sh
File metadata and controls
71 lines (60 loc) · 2.53 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
#!/bin/bash
# ============================================================
# VaultPass — Server Deployment Script
# Run this ON the server (103.235.106.93) after git clone/pull
#
# First-time setup:
# chmod +x deploy.sh && ./deploy.sh --first-run
#
# After code updates:
# ./deploy.sh
# ============================================================
set -e # exit on any error
FIRST_RUN=false
if [[ "$1" == "--first-run" ]]; then FIRST_RUN=true; fi
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo " VaultPass Deployment"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
# ── 1. Pull latest code ────────────────────────────────────────
echo "→ Pulling latest code..."
git pull origin master
# ── 2. First-run only: install Node deps & create .env ────────
if $FIRST_RUN; then
echo "→ Installing dependencies..."
cd backend && npm install && cd ..
cd frontend && npm install && cd ..
echo ""
echo "⚠️ FIRST RUN SETUP"
echo " Copy backend/.env.server to backend/.env and fill in:"
echo " - JWT_SECRET and JWT_REFRESH_SECRET (random 32+ char strings)"
echo " - MICROSOFT_CLIENT_SECRET (from Azure Portal)"
echo ""
echo " Example command:"
echo " cp backend/.env.server backend/.env && nano backend/.env"
echo ""
read -p "Press ENTER after you have set up backend/.env ..."
echo "→ Running database migrations..."
cd backend
npm run db:migrate
npm run db:migrate2
npm run db:migrate3
cd ..
fi
# ── 3. Build frontend (React → static files) ──────────────────
echo "→ Building React frontend..."
cd frontend && npm run build && cd ..
# ── 4. Compile backend TypeScript ─────────────────────────────
echo "→ Compiling backend TypeScript..."
cd backend && npm run build && cd ..
# ── 5. (Re)start with pm2 ─────────────────────────────────────
echo "→ Starting with pm2..."
if pm2 list | grep -q "vaultpass"; then
pm2 restart vaultpass
else
pm2 start ecosystem.config.js
pm2 save
fi
echo ""
echo "✅ VaultPass is running at http://103.235.106.93:5000"
echo " pm2 logs vaultpass → view live logs"
echo " pm2 status → check process status"