feat: Update Docker entrypoint scripts to create admin account on container startup
This commit is contained in:
@@ -134,19 +134,19 @@ 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. **Create the default admin account automatically**
|
5. **Admin account is created when container starts (not during build)**
|
||||||
6. Start the production server
|
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. **Create the default admin account automatically**
|
4. **Admin account is created when container starts (not during build)**
|
||||||
5. Start the production server
|
5. Start the production server
|
||||||
|
|
||||||
## Default Admin Account
|
## Default Admin Account
|
||||||
|
|
||||||
Both development and production Docker builds automatically create a default admin account with these credentials:
|
Both development and production Docker containers automatically create a default admin account **when the container starts** (not during build). This ensures the database is properly persisted in mounted volumes.
|
||||||
|
|
||||||
- **Email**: `admin@localhost.com`
|
- **Email**: `admin@localhost.com`
|
||||||
- **Password**: `admin123456`
|
- **Password**: `admin123456`
|
||||||
@@ -193,7 +193,9 @@ The script will skip creation if an admin account already exists.
|
|||||||
- For private repositories, verify authentication tokens/keys
|
- For private repositories, verify authentication tokens/keys
|
||||||
|
|
||||||
### Admin Account Issues
|
### Admin Account Issues
|
||||||
- If admin creation fails during build, check database initialization
|
- If admin creation fails during startup, check database initialization
|
||||||
- Ensure the database file is writable in the container
|
- Ensure the `./data` directory is writable on the host
|
||||||
|
- Database files are persisted in the mounted `./data` volume
|
||||||
|
- Admin account is created on container startup, not during build
|
||||||
- If admin already exists, the script will skip creation (this is normal)
|
- If admin already exists, the script will skip creation (this is normal)
|
||||||
- To recreate admin account, delete the database and rebuild the container
|
- To recreate admin account, delete the database file in `./data/` and restart the container
|
||||||
|
|||||||
@@ -32,11 +32,12 @@ COPY . .
|
|||||||
# Build the application for production
|
# Build the application for production
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
|
||||||
# Create the default admin account
|
# Copy the entrypoint script
|
||||||
RUN node scripts/create-admin.js
|
COPY docker-entrypoint.sh /docker-entrypoint.sh
|
||||||
|
RUN chmod +x /docker-entrypoint.sh
|
||||||
|
|
||||||
# Expose the default Next.js port
|
# Expose the default Next.js port
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
|
|
||||||
# Start the production server
|
# Use the entrypoint script
|
||||||
CMD ["npm", "start"]
|
ENTRYPOINT ["/docker-entrypoint.sh"]
|
||||||
|
|||||||
@@ -16,11 +16,12 @@ RUN npm install
|
|||||||
# Copy the rest of the app
|
# Copy the rest of the app
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
# Create the default admin account for development
|
# Copy the development entrypoint script
|
||||||
RUN node scripts/create-admin.js
|
COPY docker-entrypoint-dev.sh /docker-entrypoint-dev.sh
|
||||||
|
RUN chmod +x /docker-entrypoint-dev.sh
|
||||||
|
|
||||||
# Expose the default Next.js port
|
# Expose the default Next.js port
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
|
|
||||||
# Start the dev server
|
# Use the development entrypoint script
|
||||||
CMD ["npm", "run", "dev"]
|
ENTRYPOINT ["/docker-entrypoint-dev.sh"]
|
||||||
|
|||||||
@@ -26,4 +26,4 @@ docker-compose -f docker-compose.prod.yml down
|
|||||||
docker-compose -f docker-compose.prod.yml up -d
|
docker-compose -f docker-compose.prod.yml up -d
|
||||||
|
|
||||||
echo Deployment completed successfully!
|
echo Deployment completed successfully!
|
||||||
echo Application is running at http://localhost:3000
|
echo Application is running at http://localhost:3001
|
||||||
|
|||||||
@@ -29,4 +29,4 @@ docker-compose -f docker-compose.prod.yml down
|
|||||||
docker-compose -f docker-compose.prod.yml up -d
|
docker-compose -f docker-compose.prod.yml up -d
|
||||||
|
|
||||||
echo "Deployment completed successfully!"
|
echo "Deployment completed successfully!"
|
||||||
echo "Application is running at http://localhost:3000"
|
echo "Application is running at http://localhost:3001"
|
||||||
|
|||||||
17
docker-entrypoint-dev.sh
Normal file
17
docker-entrypoint-dev.sh
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Development container startup script
|
||||||
|
# This runs when the development container starts
|
||||||
|
|
||||||
|
echo "🚀 Starting development environment..."
|
||||||
|
|
||||||
|
# Ensure data directory exists
|
||||||
|
mkdir -p /app/data
|
||||||
|
|
||||||
|
# Create admin account if it doesn't exist
|
||||||
|
echo "🔧 Setting up admin account..."
|
||||||
|
node scripts/create-admin.js
|
||||||
|
|
||||||
|
# Start the development server
|
||||||
|
echo "✅ Starting development server..."
|
||||||
|
exec npm run dev
|
||||||
17
docker-entrypoint.sh
Normal file
17
docker-entrypoint.sh
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Container startup script
|
||||||
|
# This runs when the container starts, not during build
|
||||||
|
|
||||||
|
echo "🚀 Starting application..."
|
||||||
|
|
||||||
|
# Ensure data directory exists
|
||||||
|
mkdir -p /app/data
|
||||||
|
|
||||||
|
# Create admin account if it doesn't exist
|
||||||
|
echo "🔧 Setting up admin account..."
|
||||||
|
node scripts/create-admin.js
|
||||||
|
|
||||||
|
# Start the application
|
||||||
|
echo "✅ Starting production server..."
|
||||||
|
exec npm start
|
||||||
Reference in New Issue
Block a user