-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.ps1
More file actions
69 lines (54 loc) · 1.68 KB
/
deploy.ps1
File metadata and controls
69 lines (54 loc) · 1.68 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
# SingFLEX Deployment Script
# Deploy to: renny@onetv.ng:/var/app/sf3
$SERVER = "renny@onetv.ng"
$DEPLOY_PATH = "/var/app/sf3"
$LOCAL_PATH = "C:\Users\HP\app\ihub"
Write-Host "🚀 Starting deployment to $SERVER..." -ForegroundColor Cyan
# Create tar archive excluding unnecessary files
Write-Host "📦 Creating deployment package..." -ForegroundColor Yellow
$archiveName = "singflex-deploy-$(Get-Date -Format 'yyyyMMdd-HHmmss').tar.gz"
# Use tar (built into Windows 10+)
tar -czf $archiveName `
--exclude='node_modules' `
--exclude='.next' `
--exclude='dist' `
--exclude='uploads' `
--exclude='.env' `
--exclude='.env.local' `
--exclude='.git' `
--exclude='*.log' `
-C $LOCAL_PATH .
Write-Host "✅ Package created: $archiveName" -ForegroundColor Green
# Upload to server
Write-Host "📤 Uploading to server..." -ForegroundColor Yellow
scp $archiveName "${SERVER}:${DEPLOY_PATH}/"
# Extract and setup on server
Write-Host "📂 Extracting on server..." -ForegroundColor Yellow
$remoteCommands = @"
cd $DEPLOY_PATH
tar -xzf $archiveName
rm $archiveName
echo 'Files extracted'
cd hub
echo 'Installing frontend dependencies...'
npm install --production
cd ../hubx
echo 'Installing backend dependencies...'
npm install --production
cd ../hub
echo 'Building frontend...'
npm run build
cd ../hubx
echo 'Building backend...'
npm run build
echo 'Deployment complete!'
echo 'Next steps:'
echo '1. Update .env files in hub/ and hubx/'
echo '2. Configure database connection'
echo '3. Run migrations'
echo '4. Start PM2 services'
"@
ssh $SERVER $remoteCommands
# Clean up local archive
Remove-Item $archiveName
Write-Host "🎉 Deployment finished!" -ForegroundColor Green