feat: Update Docker deployment scripts and configurations for default admin account creation

This commit is contained in:
2025-07-28 21:55:11 +02:00
parent aada481c0a
commit 225d16c1c9
5 changed files with 20 additions and 14 deletions

View File

@@ -22,14 +22,16 @@ docker-compose up
docker-compose -f docker-compose.prod.yml up --build docker-compose -f docker-compose.prod.yml up --build
``` ```
**Note**: Both development and production Docker builds automatically create the default admin account.
### 2. Deploy from Git Repository ### 2. Deploy from Git Repository
#### Using Environment Variables #### Using Environment Variables
Create a `.env` file with: Create a `.env` file with:
```env ```env
GIT_REPO_URL=https://github.com/yourusername/your-repo.git GIT_REPO_URL=https://git.wastpol.pl/Admin/panel.git
GIT_BRANCH=main GIT_BRANCH=ui-fix
GIT_COMMIT=abc123 # Optional: specific commit hash GIT_COMMIT=abc123 # Optional: specific commit hash
``` ```
@@ -42,8 +44,8 @@ docker-compose -f docker-compose.prod.yml up --build
```bash ```bash
docker build \ docker build \
--build-arg GIT_REPO_URL=https://github.com/yourusername/your-repo.git \ --build-arg GIT_REPO_URL=https://git.wastpol.pl/Admin/panel.git \
--build-arg GIT_BRANCH=main \ --build-arg GIT_BRANCH=ui-fix \
--build-arg GIT_COMMIT=abc123 \ --build-arg GIT_COMMIT=abc123 \
-t your-app . -t your-app .
``` ```
@@ -52,10 +54,10 @@ docker build \
```bash ```bash
# Linux/Mac # Linux/Mac
./deploy.sh https://github.com/yourusername/your-repo.git main abc123 ./deploy.sh https://git.wastpol.pl/Admin/panel.git ui-fix abc123
# Windows # Windows
deploy.bat https://github.com/yourusername/your-repo.git main abc123 deploy.bat https://git.wastpol.pl/Admin/panel.git ui-fix abc123
``` ```
## Private Repositories ## Private Repositories
@@ -65,13 +67,13 @@ For private repositories, you have several options:
### 1. SSH Keys (Recommended for development) ### 1. SSH Keys (Recommended for development)
```bash ```bash
# Build with SSH URL # Build with SSH URL
docker build --build-arg GIT_REPO_URL=git@github.com:yourusername/your-repo.git . docker build --build-arg GIT_REPO_URL=git@git.wastpol.pl:Admin/panel.git .
``` ```
### 2. Personal Access Token ### 2. Personal Access Token
```bash ```bash
# Build with token in URL # Build with token in URL
docker build --build-arg GIT_REPO_URL=https://token@github.com/yourusername/your-repo.git . docker build --build-arg GIT_REPO_URL=https://username:token@git.wastpol.pl/Admin/panel.git .
``` ```
### 3. Docker Secrets (Recommended for production) ### 3. Docker Secrets (Recommended for production)
@@ -82,7 +84,7 @@ services:
build: build:
context: . context: .
args: args:
- GIT_REPO_URL=https://github.com/yourusername/your-repo.git - GIT_REPO_URL=https://git.wastpol.pl/Admin/panel.git
secrets: secrets:
- git_token - git_token
secrets: secrets:
@@ -117,8 +119,8 @@ jobs:
```bash ```bash
# Set environment variables in your CI/CD system # Set environment variables in your CI/CD system
export GIT_REPO_URL="https://github.com/yourusername/your-repo.git" export GIT_REPO_URL="https://git.wastpol.pl/Admin/panel.git"
export GIT_BRANCH="main" export GIT_BRANCH="ui-fix"
export GIT_COMMIT="$CI_COMMIT_SHA" export GIT_COMMIT="$CI_COMMIT_SHA"
# Deploy # Deploy
@@ -144,7 +146,7 @@ When `GIT_REPO_URL` is not provided:
## Default Admin Account ## Default Admin Account
The Docker build process automatically creates a default admin account with these credentials: Both development and production Docker builds automatically create a default admin account with these credentials:
- **Email**: `admin@localhost.com` - **Email**: `admin@localhost.com`
- **Password**: `admin123456` - **Password**: `admin123456`

View File

@@ -16,6 +16,9 @@ RUN npm install
# Copy the rest of the app # Copy the rest of the app
COPY . . COPY . .
# Create the default admin account for development
RUN node scripts/create-admin.js
# Expose the default Next.js port # Expose the default Next.js port
EXPOSE 3000 EXPOSE 3000

View File

@@ -4,7 +4,7 @@ REM Usage: deploy.bat [git_repo_url] [branch] [commit_hash]
set GIT_REPO_URL=%1 set GIT_REPO_URL=%1
set GIT_BRANCH=%2 set GIT_BRANCH=%2
if "%GIT_BRANCH%"=="" set GIT_BRANCH=main if "%GIT_BRANCH%"=="" set GIT_BRANCH=ui-fix
set GIT_COMMIT=%3 set GIT_COMMIT=%3
if "%GIT_REPO_URL%"=="" ( if "%GIT_REPO_URL%"=="" (

View File

@@ -7,7 +7,7 @@ set -e
# Default values # Default values
GIT_REPO_URL=${1:-""} GIT_REPO_URL=${1:-""}
GIT_BRANCH=${2:-"main"} GIT_BRANCH=${2:-"ui-fix"}
GIT_COMMIT=${3:-""} GIT_COMMIT=${3:-""}
if [ -z "$GIT_REPO_URL" ]; then if [ -z "$GIT_REPO_URL" ]; then

View File

@@ -8,6 +8,7 @@
"build": "next build", "build": "next build",
"start": "next start", "start": "next start",
"lint": "next lint", "lint": "next lint",
"create-admin": "node scripts/create-admin.js",
"test": "jest", "test": "jest",
"test:watch": "jest --watch", "test:watch": "jest --watch",
"test:coverage": "jest --coverage", "test:coverage": "jest --coverage",