124 lines
6.1 KiB
Makefile
124 lines
6.1 KiB
Makefile
# ─── Heimdall — Development & Deployment ──────────────────────────
|
|
.DEFAULT_GOAL := help
|
|
.PHONY: help build test docker-up docker-down docker-build clean dev backup backup-alarik restore backup-test
|
|
|
|
help: ## Show this help
|
|
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | \
|
|
awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
|
|
|
|
build: ## Build the .NET solution
|
|
dotnet build
|
|
|
|
test: ## Run all tests
|
|
dotnet test
|
|
|
|
test-watch: ## Run tests in watch mode
|
|
dotnet watch test --project tests/Heimdall.Domain.Tests
|
|
|
|
clean: ## Clean build artifacts
|
|
dotnet clean && rm -rf src/**/bin src/**/obj tests/**/bin tests/**/obj
|
|
|
|
# ─── Docker ──────────────────────────────────────────────────────
|
|
|
|
docker-up: ## Start all services (dev)
|
|
docker compose -f docker/docker-compose.yml -f docker/docker-compose.override.yml up -d
|
|
|
|
docker-down: ## Stop all services
|
|
docker compose -f docker/docker-compose.yml down -v
|
|
|
|
docker-build: ## Rebuild images without cache
|
|
docker compose -f docker/docker-compose.yml build --no-cache
|
|
|
|
docker-logs: ## Tail logs
|
|
docker compose -f docker/docker-compose.yml logs -f
|
|
|
|
docker-ps: ## List running services
|
|
docker compose -f docker/docker-compose.yml ps
|
|
|
|
docker-reset: ## Stop and remove everything
|
|
docker compose -f docker/docker-compose.yml down -v --rmi all
|
|
|
|
# ─── Deployment ──────────────────────────────────────────────────
|
|
|
|
deploy: docker-build docker-up ## Build and deploy
|
|
|
|
# ─── Versioning / Release (GitVersion) ──────────────────────────
|
|
|
|
version: ## Show GitVersion versions (central + agent)
|
|
@export PATH="$$PATH:$$HOME/.dotnet/tools"; \
|
|
if ! command -v dotnet-gitversion >/dev/null 2>&1; then dotnet tool install --global GitVersion.Tool --version 6.8.1 >/dev/null; fi; \
|
|
echo "Central (GitVersion.yml):"; \
|
|
dotnet-gitversion -config GitVersion.yml -output json 2>/dev/null | python3 -c "import json,sys; d=json.load(sys.stdin); print(' SemVer:', d['SemVer'], '| MajorMinorPatch:', d['MajorMinorPatch'])" 2>/dev/null || echo " (erreur — pas de tag v* ?)"; \
|
|
echo "Agent (GitVersion.Agent.yml):"; \
|
|
dotnet-gitversion -config GitVersion.Agent.yml -output json 2>/dev/null | python3 -c "import json,sys; d=json.load(sys.stdin); print(' SemVer:', d['SemVer'], '| MajorMinorPatch:', d['MajorMinorPatch'])" 2>/dev/null || echo " (erreur — pas de tag agent-v* ? bug GitVersion tag-prefix)"
|
|
|
|
version-tag: ## Tag la version courante (usage: make version-tag TAG=v1.0.0)
|
|
@test -n "$(TAG)" || (echo "Usage: make version-tag TAG=v1.0.0"; exit 1); \
|
|
git tag "$(TAG)" && git push origin "$(TAG)"
|
|
|
|
version-tag-agent: ## Tag la version agent (usage: make version-tag-agent TAG=agent-v1.0.0)
|
|
@test -n "$(TAG)" || (echo "Usage: make version-tag-agent TAG=agent-v1.0.0"; exit 1); \
|
|
git tag "$(TAG)" && git push origin "$(TAG)"
|
|
|
|
# ─── Database ────────────────────────────────────────────────────
|
|
|
|
migration-add: ## Add a new EF migration (usage: make migration-add NAME=xxx)
|
|
dotnet ef migrations add $(NAME) -p src/Heimdall.Infrastructure
|
|
|
|
migration-remove: ## Remove last migration
|
|
dotnet ef migrations remove -p src/Heimdall.Infrastructure
|
|
|
|
# ─── Dev helpers ─────────────────────────────────────────────────
|
|
|
|
dev-api: ## Run combined API+Web in development mode (API and Blazor UI in one process)
|
|
DATABASE_URL="Host=localhost;Port=5432;Database=heimdall;Username=heimdall;Password=heimdall" \
|
|
JWT__Key="ThisIsADevKeyThatIsAtLeast32BytesLong!!" \
|
|
ASPNETCORE_ENVIRONMENT=Development \
|
|
Cors__AllowedOrigins="*" \
|
|
dotnet run --project src/Heimdall.Web
|
|
|
|
dev-web: ## Run combined API+Web+Jobs in development mode (single process)
|
|
DATABASE_URL="Host=localhost;Port=5432;Database=heimdall;Username=heimdall;Password=heimdall" \
|
|
JWT__Key="ThisIsADevKeyThatIsAtLeast32BytesLong!!" \
|
|
ASPNETCORE_ENVIRONMENT=Development \
|
|
Cors__AllowedOrigins="*" \
|
|
dotnet run --project src/Heimdall.Web
|
|
|
|
# ─── Backup & Restore ──────────────────────────────────────────
|
|
|
|
backup: ## Run PostgreSQL backup (daily — pg_dump + upload to Alarik/S3)
|
|
chmod +x docker/scripts/backup.sh
|
|
POSTGRES_HOST=localhost POSTGRES_PORT=5432 \
|
|
POSTGRES_DB=heimdall POSTGRES_USER=heimdall POSTGRES_PASSWORD=heimdall \
|
|
./docker/scripts/backup.sh
|
|
|
|
backup-alarik: ## Run Alarik/S3 mirror backup (weekly — snapshots + recordings)
|
|
chmod +x docker/scripts/backup-alarik.sh
|
|
./docker/scripts/backup-alarik.sh
|
|
|
|
restore: ## Restore PostgreSQL from latest backup (⚠️ drops current DB)
|
|
chmod +x docker/scripts/restore.sh
|
|
POSTGRES_HOST=localhost POSTGRES_PORT=5432 \
|
|
POSTGRES_DB=heimdall POSTGRES_USER=heimdall POSTGRES_PASSWORD=heimdall \
|
|
./docker/scripts/restore.sh --latest --yes
|
|
|
|
restore-file: ## Restore from a specific backup file (usage: make restore-file FILE=/path/to/dump.sql.gz)
|
|
@test -n "$(FILE)" || (echo "Usage: make restore-file FILE=/path/to/dump.sql.gz"; exit 1)
|
|
chmod +x docker/scripts/restore.sh
|
|
POSTGRES_HOST=localhost POSTGRES_PORT=5432 \
|
|
POSTGRES_DB=heimdall POSTGRES_USER=heimdall POSTGRES_PASSWORD=heimdall \
|
|
./docker/scripts/restore.sh --file "$(FILE)" --yes
|
|
|
|
backup-test: ## Run backup/restore E2E test (isolated PostgreSQL)
|
|
chmod +x docker/scripts/test-backup-restore.sh
|
|
./docker/scripts/test-backup-restore.sh
|
|
|
|
backup-up: ## Start backup cron service (daily PG + weekly Alarik mirror)
|
|
docker compose -f docker/docker-compose.yml -f docker/docker-compose.backup.yml up -d backup
|
|
|
|
backup-down: ## Stop backup cron service
|
|
docker compose -f docker/docker-compose.yml -f docker/docker-compose.backup.yml down backup
|
|
|
|
backup-logs: ## Tail backup service logs
|
|
docker compose -f docker/docker-compose.yml -f docker/docker-compose.backup.yml logs -f backup
|