diff --git a/DEPLOYMENT_GUIDE.md b/DEPLOYMENT_GUIDE.md index 53fbb86..4b8af92 100644 --- a/DEPLOYMENT_GUIDE.md +++ b/DEPLOYMENT_GUIDE.md @@ -23,8 +23,8 @@ This guide covers deploying PicPeak using Docker Compose with direct port exposu 1. **Clone the repository** ```bash - git clone https://github.com/yourusername/wedding-photo-sharing.git - cd wedding-photo-sharing + git clone https://github.com/the-luap/picpeak.git + cd picpeak ``` 2. **Set up environment** @@ -119,20 +119,66 @@ By default, services are exposed on: ### Initial Admin Setup -The admin credentials are generated during first startup. Check the logs: +When deploying for the first time, an admin account is automatically created with a secure random password. You need to retrieve this password to access the admin panel. +#### Finding the Admin Password + +**Option 1: Check the backend logs** (recommended) ```bash -docker compose logs backend | grep -A 5 "Admin user created" +# View the initial setup logs +docker compose logs backend | grep -A 10 "Admin user created" ``` -Or use the helper script: +You should see output like: +``` +======================================== +āœ… Admin user created successfully! +======================================== +Email: admin@example.com +Password: BraveTiger6231! + +āš ļø IMPORTANT: +1. Save these credentials securely +2. Please change the password after first login +======================================== +``` + +**Note**: You login with the **email address**, not a username! + +**Option 2: Check the saved credentials file** ```bash +# The password is saved in the backend container +docker exec picpeak-backend cat data/ADMIN_CREDENTIALS.txt +``` + +**Option 3: Use the helper script** +```bash +# Show current admin username and email (password is hidden) docker exec picpeak-backend node scripts/show-admin-credentials.js -# To reset password +# Reset the admin password to a new random password docker exec picpeak-backend node scripts/show-admin-credentials.js --reset ``` +#### Important Notes + +- **Login requires the email address**, not username +- The admin password is only shown once during initial setup +- If you lose the password, use the `--reset` option to generate a new one +- You must change the password on first login (enforced by the system) +- Password requirements: minimum 12 characters, mixed case, numbers, and special characters + +#### Configuring Admin Email + +By default, the admin email is `admin@example.com`. To use a different email address, set it in your `.env` file before first deployment: + +```env +# .env +ADMIN_EMAIL=your-email@yourdomain.com +``` + +**Note**: This only works on first deployment. To change the admin email after deployment, you'll need to update it in the database or create a new admin user through the admin panel. + ## šŸ”’ Reverse Proxy Setup For production deployments, you should use a reverse proxy for SSL/HTTPS. The application exposes ports directly, allowing you to use any reverse proxy solution. diff --git a/backend/migrations/core/001_init.js b/backend/migrations/core/001_init.js index d9e2a27..fb2f394 100644 --- a/backend/migrations/core/001_init.js +++ b/backend/migrations/core/001_init.js @@ -18,9 +18,13 @@ exports.up = async function(knex) { const generatedPassword = generateReadablePassword(); const passwordHash = await bcrypt.hash(generatedPassword, 12); // Increased rounds for better security + // Get admin credentials from environment or use defaults + const adminUsername = process.env.ADMIN_USERNAME || 'admin'; + const adminEmail = process.env.ADMIN_EMAIL || 'admin@example.com'; + await knex('admin_users').insert({ - username: 'admin', - email: 'admin@example.com', + username: adminUsername, + email: adminEmail, password_hash: passwordHash, created_at: new Date() }); @@ -36,7 +40,7 @@ PicPeak Admin Credentials Your admin account has been created with these credentials: -Username: admin +Email: ${adminEmail} Password: ${generatedPassword} IMPORTANT SECURITY NOTES: @@ -47,6 +51,8 @@ IMPORTANT SECURITY NOTES: Login URL: ${process.env.ADMIN_URL || 'http://localhost:3001'}/admin +Login with the email address shown above + Generated on: ${new Date().toISOString()} ======================================== `; @@ -65,7 +71,7 @@ Generated on: ${new Date().toISOString()} console.log('\n========================================'); console.log('āœ… Admin user created successfully!'); console.log('========================================'); - console.log('Username: admin'); + console.log(`Email: ${adminEmail}`); console.log(`Password: ${generatedPassword}`); console.log('\nāš ļø IMPORTANT:'); console.log('1. Save these credentials securely'); diff --git a/docker-compose.yml b/docker-compose.yml index a4cca75..cff4baf 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,3 @@ -version: '3.8' - services: backend: build: