Fix permission error when writing admin credentials
Mirror to GitHub / mirror (push) Successful in 25s
Test and Lint / backend-test (push) Successful in 1m21s
continuous-integration/drone/push Build is passing
Test and Lint / frontend-test (push) Successful in 2m0s
Version and Release / version-bump (push) Successful in 28s
Version and Release / trigger-drone (push) Has been skipped

- Changed credential file location from /app/ to /app/data/
- Added directory creation with recursive flag
- Updated console messages to show correct file location
- The data/ directory is already owned by nodejs user in Dockerfile

The error occurred because the nodejs user doesn't have write
permission to /app/ directory, but does have permission to /app/data/
which is explicitly created and chowned in the Dockerfile.
This commit is contained in:
2025-07-25 13:20:44 +02:00
parent 055de06315
commit 596bba2c1b
2 changed files with 12 additions and 4 deletions
+1 -1
View File
@@ -180,7 +180,7 @@ docker-compose up -d
# Run database migrations
docker-compose exec backend npm run migrate
# Admin credentials will be displayed and saved to ADMIN_CREDENTIALS.txt
# Admin credentials will be displayed and saved to /data/ADMIN_CREDENTIALS.txt
```
#### Step 4: Configure Nginx
+11 -3
View File
@@ -26,7 +26,15 @@ exports.up = async function(knex) {
});
// Save the generated password to a file for the user to retrieve
const setupInfoPath = path.join(__dirname, '..', '..', 'ADMIN_CREDENTIALS.txt');
const dataDir = path.join(__dirname, '..', '..', 'data');
const setupInfoPath = path.join(dataDir, 'ADMIN_CREDENTIALS.txt');
// Ensure data directory exists
try {
await fs.mkdir(dataDir, { recursive: true });
} catch (error) {
// Directory might already exist, that's okay
}
const setupInfo = `
========================================
PicPeak Admin Credentials
@@ -58,8 +66,8 @@ Generated on: ${new Date().toISOString()}
console.log(`Password: ${generatedPassword}`);
console.log('\n⚠️ IMPORTANT:');
console.log('1. Save these credentials securely');
console.log('2. You will be required to change the password on first login');
console.log('3. Credentials are also saved in: ADMIN_CREDENTIALS.txt');
console.log('2. Please change the password after first login');
console.log('3. Credentials are also saved in: data/ADMIN_CREDENTIALS.txt');
console.log('========================================\n');
}