-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy-setup.js
More file actions
156 lines (125 loc) Β· 4.73 KB
/
Copy pathdeploy-setup.js
File metadata and controls
156 lines (125 loc) Β· 4.73 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
#!/usr/bin/env node
const fs = require('fs');
const path = require('path');
const crypto = require('crypto');
console.log('π EthioHeritage360 Deployment Setup');
console.log('=====================================\n');
// Generate secure secrets
const generateSecret = (length = 64) => {
return crypto.randomBytes(length).toString('hex');
};
const jwtSecret = generateSecret();
const jwtRefreshSecret = generateSecret();
console.log('β
Generated secure JWT secrets');
// Create environment variables for Netlify
const netlifyEnvVars = `
# Copy these environment variables to your Netlify site settings:
# Site Settings β Environment Variables
# π Security (REQUIRED)
NODE_ENV=production
JWT_SECRET=${jwtSecret}
JWT_REFRESH_SECRET=${jwtRefreshSecret}
BCRYPT_SALT_ROUNDS=12
# ποΈ Database (REQUIRED)
MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/ethioheritage360?retryWrites=true&w=majority
DB_NAME=ethioheritage360
# π CORS (Update with your Netlify URL)
ALLOWED_ORIGINS=https://your-site-name.netlify.app
# π§ Email Configuration (Optional)
EMAIL_SERVICE=gmail
EMAIL_USER=your-email@gmail.com
EMAIL_PASS=your-app-password
FROM_EMAIL=noreply@ethioheritage360.com
FROM_NAME=EthioHeritage360
# πΊοΈ Map Services (Optional)
MAPBOX_ACCESS_TOKEN=your-mapbox-access-token
GOOGLE_MAPS_API_KEY=your-google-maps-api-key
# βοΈ File Upload (Recommended - Cloudinary)
CLOUDINARY_CLOUD_NAME=your-cloudinary-cloud-name
CLOUDINARY_API_KEY=your-cloudinary-api-key
CLOUDINARY_API_SECRET=your-cloudinary-api-secret
# π Rate Limiting
RATE_LIMIT_WINDOW_MS=900000
RATE_LIMIT_MAX_REQUESTS=1000
# π Monitoring (Optional)
SENTRY_DSN=https://your-sentry-dsn
GOOGLE_ANALYTICS_ID=GA-XXXXXXXXX
# β‘ Performance
CACHE_TTL=3600
MAX_FILE_SIZE=10485760
`;
// Write environment variables to file
fs.writeFileSync('.env.netlify', netlifyEnvVars);
console.log('β
Created .env.netlify with generated secrets');
// Create deployment checklist
const checklist = `
# π Deployment Checklist for EthioHeritage360
## Pre-Deployment
- [ ] Code committed and pushed to Git repository
- [ ] All tests passing locally
- [ ] Build process working: \`npm run build:netlify\`
## MongoDB Atlas Setup
- [ ] MongoDB Atlas account created
- [ ] Cluster created and configured
- [ ] Database user created with read/write permissions
- [ ] Network access configured (IP whitelist)
- [ ] Connection string obtained
## Netlify Setup
- [ ] Netlify account created
- [ ] Site connected to Git repository
- [ ] Build settings configured:
- Base directory: (empty)
- Build command: npm run build:netlify
- Publish directory: client/dist
- Functions directory: netlify/functions
## Environment Variables
Copy from .env.netlify file to Netlify Dashboard:
- [ ] NODE_ENV=production
- [ ] JWT_SECRET (generated)
- [ ] JWT_REFRESH_SECRET (generated)
- [ ] MONGODB_URI (from Atlas)
- [ ] DB_NAME=ethioheritage360
- [ ] ALLOWED_ORIGINS (your Netlify URL)
- [ ] Other optional variables as needed
## Testing
- [ ] Frontend loads at Netlify URL
- [ ] API health check: https://your-site.netlify.app/.netlify/functions/api/health
- [ ] Database connection working
- [ ] Authentication flow working
- [ ] File uploads working (if configured)
## Optional Enhancements
- [ ] Custom domain configured
- [ ] SSL certificate active (automatic with Netlify)
- [ ] Analytics enabled
- [ ] Error monitoring configured
- [ ] Performance optimization completed
## Post-Deployment
- [ ] Create initial admin user
- [ ] Test all major functionality
- [ ] Monitor logs and performance
- [ ] Set up backup procedures
- [ ] Document any custom configurations
---
π Your EthioHeritage360 app will be live at: https://your-site-name.netlify.app
Need help? Check:
- DEPLOYMENT_GUIDE.md for detailed instructions
- DATABASE_SETUP.md for MongoDB Atlas configuration
- Netlify documentation: https://docs.netlify.com/
`;
fs.writeFileSync('deployment-checklist.md', checklist);
console.log('β
Created deployment-checklist.md');
// Display next steps
console.log('\nπ― Next Steps:');
console.log('==============');
console.log('1. Set up MongoDB Atlas (see DATABASE_SETUP.md)');
console.log('2. Copy environment variables from .env.netlify to Netlify');
console.log('3. Connect your Git repository to Netlify');
console.log('4. Deploy and test your application');
console.log('5. Follow deployment-checklist.md for complete setup');
console.log('\nπ For detailed instructions, see DEPLOYMENT_GUIDE.md');
console.log('\nπ IMPORTANT SECURITY NOTES:');
console.log('- Never commit .env.netlify to version control');
console.log('- Use the generated JWT secrets in production');
console.log('- Update ALLOWED_ORIGINS with your actual domain');
console.log('- Regularly rotate your secrets');
console.log('\n⨠Happy deploying!');