feat: Automatically create default admin account during Docker build process

This commit is contained in:
2025-07-28 21:48:28 +02:00
parent c767e65819
commit aada481c0a
2 changed files with 37 additions and 2 deletions

View File

@@ -132,13 +132,39 @@ When `GIT_REPO_URL` is provided:
2. If `GIT_COMMIT` is specified, checkout that specific commit 2. If `GIT_COMMIT` is specified, checkout that specific commit
3. Install dependencies from the repository's package.json 3. Install dependencies from the repository's package.json
4. Build the application 4. Build the application
5. Start the production server 5. **Create the default admin account automatically**
6. Start the production server
When `GIT_REPO_URL` is not provided: When `GIT_REPO_URL` is not provided:
1. Copy local files into the container 1. Copy local files into the container
2. Install dependencies 2. Install dependencies
3. Build the application 3. Build the application
4. Start the production server 4. **Create the default admin account automatically**
5. Start the production server
## Default Admin Account
The Docker build process automatically creates a default admin account with these credentials:
- **Email**: `admin@localhost.com`
- **Password**: `admin123456`
- **Role**: `admin`
⚠️ **Important Security Note**: Please change the default password immediately after your first login!
### Manual Admin Account Creation
If you need to create the admin account manually (for development or testing):
```bash
# Using npm script
npm run create-admin
# Or directly
node scripts/create-admin.js
```
The script will skip creation if an admin account already exists.
## Environment Variables ## Environment Variables
@@ -163,3 +189,9 @@ When `GIT_REPO_URL` is not provided:
### Permission Issues ### Permission Issues
- Ensure the Docker daemon has network access - Ensure the Docker daemon has network access
- For private repositories, verify authentication tokens/keys - For private repositories, verify authentication tokens/keys
### Admin Account Issues
- If admin creation fails during build, check database initialization
- Ensure the database file is writable in the container
- If admin already exists, the script will skip creation (this is normal)
- To recreate admin account, delete the database and rebuild the container

View File

@@ -32,6 +32,9 @@ COPY . .
# Build the application for production # Build the application for production
RUN npm run build RUN npm run build
# Create the default admin account
RUN node scripts/create-admin.js
# Expose the default Next.js port # Expose the default Next.js port
EXPOSE 3000 EXPOSE 3000