Files
peikarband/Makefile
Ehsan.Asadi 432aa63e36 feat: implement complete CI/CD with base image strategy
- Add Woodpecker pipeline with base image support
- Separate base image build (.woodpecker-base.yml) from app build (.woodpecker.yml)
- Implement build/push separation in application pipeline
- Create Docker base image with Python 3.11, Node.js 20, and bun
- Update Dockerfile to use pre-built base image for faster builds
- Remove GitHub Actions (not needed, using Woodpecker)
- Fix Docker contexts and paths for new structure
- Update docker-compose.yml build contexts
- Fix rxconfig.py DB path for container environment
- Add ArgoCD application manifests for staging/production
- Create comprehensive documentation:
  - docs/WOODPECKER_CI_CD.md (CI/CD guide)
  - docs/BASE_IMAGE_MANAGEMENT.md (Base image management)
  - helm/peikarband/argocd/README.md (ArgoCD deployment)

Benefits:
- Build time: 8-10min → 2-3min (60-70% faster)
- Better reliability (no repeated npm/bun downloads)
- Separation of concerns (base vs application builds)
- Full pipeline: check → build → push → verify → notify
- Complete deployment automation with Helm + ArgoCD

Pipeline stages:
1. check-base-image: Verify base image availability
2. build-image: Build application (no push)
3. push-image: Push with multi-tags (latest, sha, branch)
4. verify-push: Verify successful push
5. notify: Success/failure notifications

Base image can be rebuilt via:
- Manual trigger in Woodpecker UI
- Auto trigger when Dockerfile.base changes
2025-12-30 21:50:45 +03:30

144 lines
3.9 KiB
Makefile

# Peikarband Platform - Makefile
REGISTRY ?= harbor.peikarband.ir
IMAGE_NAME ?= peikarband/landing
VERSION ?= $(shell git describe --tags --always --dirty)
HELM_RELEASE ?= peikarband
NAMESPACE ?= production
DOCKER_BUILDKIT ?= 1
.PHONY: help install dev kill-dev test lint format clean docker-up docker-down migrate
help:
@echo "Available commands:"
@echo ""
@echo "Development:"
@echo " make install - Install dependencies"
@echo " make dev - Run development server"
@echo " make kill-dev - Kill development server processes (ports 3000 & 8000)"
@echo " make test - Run tests"
@echo " make lint - Run linters"
@echo " make format - Format code"
@echo " make clean - Clean temporary files"
@echo ""
@echo "Docker:"
@echo " make docker-build - Build Docker image"
@echo " make docker-push - Push Docker image"
@echo " make docker-up - Start Docker Compose"
@echo " make docker-down - Stop Docker Compose"
@echo ""
@echo "Kubernetes/Helm:"
@echo " make helm-lint - Lint Helm chart"
@echo " make helm-package - Package Helm chart"
@echo " make helm-install - Install Helm chart"
@echo " make helm-upgrade - Upgrade Helm chart"
@echo " make helm-uninstall - Uninstall Helm chart"
@echo " make k8s-deploy - Deploy to Kubernetes"
@echo ""
@echo "Database:"
@echo " make migrate - Run database migrations"
install:
pip install -r requirements.txt
pip install -r requirements-dev.txt
pre-commit install
dev:
cd peikarband && python3 -m reflex run
kill-dev:
@echo "Killing processes on ports 3000 and 8000..."
@lsof -ti:3000 -ti:8000 2>/dev/null | xargs kill -9 2>/dev/null || true
@pkill -9 -f reflex 2>/dev/null || true
@echo "Done!"
test:
pytest tests/ -v --cov=src --cov-report=html
lint:
flake8 src/
mypy src/
black --check src/
isort --check-only src/
format:
black src/
isort src/
clean:
find . -type d -name "__pycache__" -exec rm -rf {} +
find . -type f -name "*.pyc" -delete
find . -type f -name "*.pyo" -delete
find . -type d -name ".pytest_cache" -exec rm -rf {} +
find . -type d -name ".mypy_cache" -exec rm -rf {} +
find . -type d -name "*.egg-info" -exec rm -rf {} +
rm -rf .coverage htmlcov/
rm -rf dist/
# Docker commands
docker-build:
DOCKER_BUILDKIT=$(DOCKER_BUILDKIT) docker build \
-f docker/Dockerfile \
-t $(IMAGE_NAME):$(VERSION) \
-t $(IMAGE_NAME):latest \
--build-arg VERSION=$(VERSION) \
--build-arg BUILD_DATE=$(shell date -u +'%Y-%m-%dT%H:%M:%SZ') \
.
docker-push:
docker tag $(IMAGE_NAME):$(VERSION) $(REGISTRY)/$(IMAGE_NAME):$(VERSION)
docker tag $(IMAGE_NAME):$(VERSION) $(REGISTRY)/$(IMAGE_NAME):latest
docker push $(REGISTRY)/$(IMAGE_NAME):$(VERSION)
docker push $(REGISTRY)/$(IMAGE_NAME):latest
docker-login:
@echo "Logging in to Harbor registry..."
@docker login $(REGISTRY)
docker-up:
docker-compose -f docker/docker-compose.yml up -d
docker-down:
docker-compose -f docker/docker-compose.yml down
# Helm commands
helm-lint:
helm lint helm/peikarband
helm-template:
helm template $(HELM_RELEASE) helm/peikarband --debug
helm-package:
helm package helm/peikarband --destination .
helm-install:
helm install $(HELM_RELEASE) helm/peikarband \
--namespace $(NAMESPACE) \
--create-namespace \
--set image.repository=$(REGISTRY)/$(IMAGE_NAME) \
--set image.tag=$(VERSION) \
--wait
helm-upgrade:
helm upgrade --install $(HELM_RELEASE) helm/peikarband \
--namespace $(NAMESPACE) \
--set image.repository=$(REGISTRY)/$(IMAGE_NAME) \
--set image.tag=$(VERSION) \
--wait
helm-uninstall:
helm uninstall $(HELM_RELEASE) --namespace $(NAMESPACE)
# Kubernetes deployment (full pipeline)
k8s-deploy: docker-build docker-push helm-upgrade
@echo "Deployment complete!"
@echo "Check status: kubectl get pods -n $(NAMESPACE)"
# Database
migrate:
cd peikarband && alembic -c config/alembic.ini upgrade head
seed:
cd peikarband && python3 tools/scripts/seed_database.py