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
```
**Note**: Both development and production Docker builds automatically create the default admin account.
### 2. Deploy from Git Repository
#### Using Environment Variables
Create a `.env` file with:
```env
GIT_REPO_URL=https://github.com/yourusername/your-repo.git
GIT_BRANCH=main
GIT_REPO_URL=https://git.wastpol.pl/Admin/panel.git
GIT_BRANCH=ui-fix
GIT_COMMIT=abc123 # Optional: specific commit hash
```
@@ -42,8 +44,8 @@ docker-compose -f docker-compose.prod.yml up --build
```bash
docker build \
--build-arg GIT_REPO_URL=https://github.com/yourusername/your-repo.git \
--build-arg GIT_BRANCH=main \
--build-arg GIT_REPO_URL=https://git.wastpol.pl/Admin/panel.git \
--build-arg GIT_BRANCH=ui-fix \
--build-arg GIT_COMMIT=abc123 \
-t your-app .
```
@@ -52,10 +54,10 @@ docker build \
```bash
# 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
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
@@ -65,13 +67,13 @@ For private repositories, you have several options:
### 1. SSH Keys (Recommended for development)
```bash
# 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
```bash
# 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)
@@ -82,7 +84,7 @@ services:
build:
context: .
args:
- GIT_REPO_URL=https://github.com/yourusername/your-repo.git
- GIT_REPO_URL=https://git.wastpol.pl/Admin/panel.git
secrets:
- git_token
secrets:
@@ -117,8 +119,8 @@ jobs:
```bash
# Set environment variables in your CI/CD system
export GIT_REPO_URL="https://github.com/yourusername/your-repo.git"
export GIT_BRANCH="main"
export GIT_REPO_URL="https://git.wastpol.pl/Admin/panel.git"
export GIT_BRANCH="ui-fix"
export GIT_COMMIT="$CI_COMMIT_SHA"
# Deploy
@@ -144,7 +146,7 @@ When `GIT_REPO_URL` is not provided:
## 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`
- **Password**: `admin123456`

View File

@@ -16,6 +16,9 @@ RUN npm install
# Copy the rest of the app
COPY . .
# Create the default admin account for development
RUN node scripts/create-admin.js
# Expose the default Next.js port
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_BRANCH=%2
if "%GIT_BRANCH%"=="" set GIT_BRANCH=main
if "%GIT_BRANCH%"=="" set GIT_BRANCH=ui-fix
set GIT_COMMIT=%3
if "%GIT_REPO_URL%"=="" (

View File

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

View File

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