chore: add repository strategy doc and helper scripts
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed

- Add docs/REPOSITORY_STRATEGY.md for future reference
- Add build-base-image.sh for local base image build
- Add restore-files.sh for pipeline file management
- Restore correct pipeline file names
This commit is contained in:
Ehsan.Asadi
2025-12-30 21:56:58 +03:30
parent 7f4d167ca6
commit 5fed68fc54
3 changed files with 155 additions and 0 deletions

43
build-base-image.sh Executable file
View File

@@ -0,0 +1,43 @@
#!/bin/bash
# Helper script to build and push base image locally
set -e
echo "=== Building Peikarband Base Image ==="
echo ""
# Variables
REGISTRY="hub.peikarband.ir"
IMAGE="$REGISTRY/peikarband/base"
# Build
echo "1. Building base image..."
docker build \
-f docker/Dockerfile.base \
-t "$IMAGE:latest" \
-t "$IMAGE:python3.11-node20" \
--build-arg PYTHON_VERSION=3.11 \
--build-arg NODE_VERSION=20 \
.
echo ""
echo "2. Testing base image..."
docker run --rm "$IMAGE:latest" bash -c "python --version && node --version && bun --version"
echo ""
echo "3. Login to Harbor registry..."
docker login "$REGISTRY"
echo ""
echo "4. Pushing base image..."
docker push "$IMAGE:latest"
docker push "$IMAGE:python3.11-node20"
echo ""
echo "=== ✅ Base Image Built and Pushed Successfully! ==="
echo ""
echo "Base image is now available at:"
echo " - $IMAGE:latest"
echo " - $IMAGE:python3.11-node20"
echo ""
echo "You can now run the application pipeline."

View File

@@ -0,0 +1,94 @@
# Repository Strategy
## استراتژی فعلی: Single Repository ✅
همه چیز در یک repository: `peikarband/landing`
### مزایا:
- ساده و قابل مدیریت
- همه چیز در یک جا
- مناسب برای یک پروژه
### ساختار:
```
peikarband/landing/
├── .woodpecker.yml # Application pipeline
├── .woodpecker-base.yml # Base image pipeline
├── docker/
│ ├── Dockerfile # Application
│ └── Dockerfile.base # Base image
└── ...
```
---
## استراتژی آینده: Multi Repository (اختیاری)
اگر پروژه‌های بیشتری اضافه شد، می‌توانید base را جدا کنید.
### مراحل جداسازی:
#### 1. ایجاد Repository جدید
```bash
# Create new repo
mkdir peikarband-base-images
cd peikarband-base-images
git init
# Structure
mkdir -p python311-node20
```
#### 2. انتقال Base Files
```bash
# Copy base files
cp ../landing/docker/Dockerfile.base python311-node20/Dockerfile
cp ../landing/.woodpecker-base.yml .woodpecker.yml
```
#### 3. Update Application Repository
در `peikarband/landing`:
```dockerfile
# docker/Dockerfile
ARG BASE_IMAGE=hub.peikarband.ir/peikarband/base:python311-node20
FROM ${BASE_IMAGE} AS builder
```
#### 4. Registry Organization
```
Registry Structure:
hub.peikarband.ir/
├── peikarband/base # Base images repo
│ ├── python311-node20:latest
│ └── python312-node21:latest
└── peikarband/landing # Application
└── latest
```
---
## زمان جداسازی
**جدا کنید وقتی:**
- ✅ 3+ پروژه از همان base استفاده می‌کنند
- ✅ تیم 5+ نفری دارید
- ✅ Base versioning پیچیده شد
- ✅ نیاز به CI/CD مستقل برای base دارید
**جدا نکنید وقتی:**
- ❌ فقط یک پروژه دارید (فعلی)
- ❌ تیم کوچک است (1-3 نفر)
- ❌ Base خیلی تغییر نمی‌کند
---
## توصیه
**الان:** یک repository کافیه! 👍
**آینده:** اگر پروژه دوم شروع شد، مجدداً ارزیابی کنید.

18
restore-files.sh Executable file
View File

@@ -0,0 +1,18 @@
#!/bin/bash
# Script to restore original pipeline file names
cd "$(dirname "$0")"
echo "═══ Restoring original file names ═══"
mv .woodpecker.yml .woodpecker-base.yml
mv .woodpecker-app.yml .woodpecker.yml
echo "✓ Files restored:"
ls -lh .woodpecker*.yml
echo ""
echo "Now you can:"
echo " 1. Commit the changes"
echo " 2. Push to trigger application pipeline"