feat: add bootstrap script for auto-generated credentials on fresh install

This commit is contained in:
cawcenter
2025-12-14 08:06:56 -05:00
parent fc88ad4240
commit f52372a29f
3 changed files with 71 additions and 0 deletions

7
.env.deploy Normal file
View File

@@ -0,0 +1,7 @@
# Fresh Deployment Credentials
# These will be auto-generated on first deployment
# After deployment, check the Directus container logs for the actual credentials
ADMIN_EMAIL=admin@sparkplatform.local
DB_USER=sparkuser
DB_DATABASE=directus

32
DEPLOY_INSTRUCTIONS.md Normal file
View File

@@ -0,0 +1,32 @@
# Deployment Instructions
## Fresh Install with Auto-Generated Credentials
This deployment will automatically:
1. Generate secure random passwords for all services
2. Create the Directus admin user
3. Save all credentials to a file you can retrieve
### Deploy Steps:
1. **In Coolify, set ONLY these environment variables:**
```
ADMIN_EMAIL=admin@sparkplatform.local
DB_USER=sparkuser
DB_DATABASE=directus
```
2. **Deploy the application**
3. **Retrieve your credentials:**
```bash
docker exec <directus-container-name> cat /directus/credentials.txt
```
4. **Login to Directus:**
- URL: https://spark.jumpstartscaling.com
- Email: admin@sparkplatform.local
- Password: (from credentials.txt)
### Security Note:
All passwords are randomly generated using `openssl rand -base64` and are unique per deployment.

32
directus/scripts/bootstrap.sh Executable file
View File

@@ -0,0 +1,32 @@
#!/bin/sh
set -e
# Generate random passwords if not set
export ADMIN_PASSWORD=${ADMIN_PASSWORD:-$(openssl rand -base64 32)}
export DB_PASSWORD=${DB_PASSWORD:-$(openssl rand -base64 32)}
export KEY=${KEY:-$(openssl rand -base64 64)}
export SECRET=${SECRET:-$(openssl rand -base64 64)}
# Save credentials to a file for reference
cat > /directus/credentials.txt <<EOF
===========================================
DIRECTUS ADMIN CREDENTIALS
===========================================
Admin Email: ${ADMIN_EMAIL}
Admin Password: ${ADMIN_PASSWORD}
Database User: ${DB_USER}
Database Password: ${DB_PASSWORD}
Directus Key: ${KEY}
Directus Secret: ${SECRET}
===========================================
IMPORTANT: Save these credentials securely!
===========================================
EOF
echo "✅ Credentials generated and saved to /directus/credentials.txt"
cat /directus/credentials.txt
# Start Directus
exec node cli.js bootstrap && node cli.js start