-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpackage-deploy.ps1
More file actions
98 lines (81 loc) · 2.91 KB
/
package-deploy.ps1
File metadata and controls
98 lines (81 loc) · 2.91 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
# Package deployment files for standalone build (Windows)
# Usage: .\package-deploy.ps1
$ErrorActionPreference = "Stop"
$deployDir = "deploy"
Write-Host "📦 Creating deployment package..." -ForegroundColor Cyan
# Check if build exists
if (-not (Test-Path ".next\standalone")) {
Write-Host "❌ Standalone build not found. Running build first..." -ForegroundColor Yellow
npm run build
}
# Create deployment folder
if (Test-Path $deployDir) {
Remove-Item -Path $deployDir -Recurse -Force
}
New-Item -ItemType Directory -Force -Path $deployDir | Out-Null
# Copy standalone build
Write-Host "📂 Copying standalone build..." -ForegroundColor Cyan
Copy-Item -Path ".next\standalone\*" -Destination "$deployDir\" -Recurse -Force
# Copy static files
Write-Host "📂 Copying static files..." -ForegroundColor Cyan
$staticDir = "$deployDir\.next\static"
New-Item -ItemType Directory -Force -Path $staticDir | Out-Null
if (Test-Path ".next\static") {
Copy-Item -Path ".next\static\*" -Destination $staticDir -Recurse -Force
}
# Copy public folder
Write-Host "📂 Copying public files..." -ForegroundColor Cyan
if (Test-Path "public") {
Copy-Item -Path "public" -Destination "$deployDir\public" -Recurse -Force
}
# Create .env file template
Write-Host "📝 Creating .env template..." -ForegroundColor Cyan
@"
# Supabase Configuration
NEXT_PUBLIC_SUPABASE_URL=your_supabase_url_here
NEXT_PUBLIC_SUPABASE_PUBLISHABLE_DEFAULT_KEY=your_publishable_key_here
# Service Role Key (keep secret!)
SUPABASE_SERVICE_ROLE_KEY=your_service_role_key_here
# Database URLs
DATABASE_URL=your_database_url_here
DIRECT_URL=your_direct_url_here
# Node Environment
NODE_ENV=production
PORT=3000
"@ | Out-File -FilePath "$deployDir\.env" -Encoding utf8
# Create README for deployment
$readmeContent = @"
# Deployment Instructions
1. Edit `.env` file with your actual environment variables
2. Transfer this entire folder to your server
3. On server, install Node.js (if not already installed):
```bash
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt-get install -y nodejs
```
4. Install PM2 (process manager):
```bash
sudo npm install -g pm2
```
5. Start the application:
```bash
pm2 start server.js --name reda-app --env production
pm2 save
pm2 startup
```
6. Your app will be running at http://your-server-ip:3000
## Useful PM2 Commands
- View logs: `pm2 logs reda-app`
- Restart: `pm2 restart reda-app`
- Stop: `pm2 stop reda-app`
- Monitor: `pm2 monit`
"@
$readmeContent | Out-File -FilePath "$deployDir\README.md" -Encoding utf8
Write-Host ""
Write-Host "✅ Deployment package created in '$deployDir' folder" -ForegroundColor Green
Write-Host ""
Write-Host "📝 Next steps:" -ForegroundColor Yellow
Write-Host " 1. Edit $deployDir\.env with your actual values"
Write-Host " 2. Transfer $deployDir folder to your server"
Write-Host " 3. Follow instructions in $deployDir\README.md"
Write-Host ""