Last active
June 15, 2025 17:47
-
-
Save polyglotdev/75a77e53d9d4552a4b479d98475e6f9d to your computer and use it in GitHub Desktop.
Makefile for initial set up of project
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# CloudBridge DevOps Platform - Makefile | |
# This Makefile sets up the entire project structure and provides development commands | |
.PHONY: help setup clean build test proto frontend backend docker dev-up dev-down migrate lint format | |
# Default target | |
.DEFAULT_GOAL := help | |
# Variables | |
PROJECT_NAME := cloudbridge | |
GO_VERSION := 1.21 | |
NODE_VERSION := 23.6.0 | |
# Updated to current versions as of June 2025 | |
PROTO_VERSION := 31.1 | |
PROTOC_GEN_GO_VERSION := 1.36.6 | |
PROTOC_GEN_GO_GRPC_VERSION := 1.5.1 | |
BUF_VERSION := 1.28.1 | |
DOCKER_REGISTRY := cloudbridge | |
NAMESPACE := cloudbridge-dev | |
# System detection | |
UNAME_S := $(shell uname -s) | |
UNAME_M := $(shell uname -m) | |
# Platform-specific settings | |
ifeq ($(UNAME_S),Darwin) | |
OS := darwin | |
DISTRO := macos | |
INSTALL_CMD := brew install | |
else ifeq ($(UNAME_S),Linux) | |
OS := linux | |
# Detect Linux distribution | |
DISTRO := $(shell \ | |
if [ -f /etc/os-release ]; then \ | |
. /etc/os-release && echo $ID; \ | |
elif [ -f /etc/debian_version ]; then \ | |
echo "debian"; \ | |
elif [ -f /etc/redhat-release ]; then \ | |
echo "rhel"; \ | |
elif command -v pacman >/dev/null 2>&1; then \ | |
echo "arch"; \ | |
elif command -v zypper >/dev/null 2>&1; then \ | |
echo "opensuse"; \ | |
elif command -v apk >/dev/null 2>&1; then \ | |
echo "alpine"; \ | |
else \ | |
echo "unknown"; \ | |
fi) | |
# Set install command based on distro | |
ifeq ($(DISTRO),ubuntu) | |
INSTALL_CMD := sudo apt-get update && sudo apt-get install -y | |
PKG_UPDATE := sudo apt-get update | |
else ifeq ($(DISTRO),debian) | |
INSTALL_CMD := sudo apt-get update && sudo apt-get install -y | |
PKG_UPDATE := sudo apt-get update | |
else ifeq ($(DISTRO),fedora) | |
INSTALL_CMD := sudo dnf install -y | |
PKG_UPDATE := sudo dnf check-update || true | |
else ifeq ($(DISTRO),centos) | |
INSTALL_CMD := sudo yum install -y | |
PKG_UPDATE := sudo yum check-update || true | |
else ifeq ($(DISTRO),rhel) | |
INSTALL_CMD := sudo yum install -y | |
PKG_UPDATE := sudo yum check-update || true | |
else ifeq ($(DISTRO),arch) | |
INSTALL_CMD := sudo pacman -S --noconfirm | |
PKG_UPDATE := sudo pacman -Sy | |
else ifeq ($(DISTRO),manjaro) | |
INSTALL_CMD := sudo pacman -S --noconfirm | |
PKG_UPDATE := sudo pacman -Sy | |
else ifeq ($(DISTRO),opensuse) | |
INSTALL_CMD := sudo zypper install -y | |
PKG_UPDATE := sudo zypper refresh | |
else ifeq ($(DISTRO),alpine) | |
INSTALL_CMD := sudo apk add | |
PKG_UPDATE := sudo apk update | |
else | |
INSTALL_CMD := echo "Unsupported Linux distribution: $(DISTRO). Please install manually:" | |
PKG_UPDATE := echo "Unknown package manager" | |
endif | |
else | |
$(error Unsupported operating system: $(UNAME_S)) | |
endif | |
# Architecture detection and mapping | |
ifeq ($(UNAME_M),arm64) | |
ARCH := arm64 | |
PROTOC_ARCH := aarch_64 | |
else ifeq ($(UNAME_M),aarch64) | |
ARCH := arm64 | |
PROTOC_ARCH := aarch_64 | |
else ifeq ($(UNAME_M),x86_64) | |
ARCH := amd64 | |
PROTOC_ARCH := x86_64 | |
else | |
$(error Unsupported architecture: $(UNAME_M)) | |
endif | |
# Colors for output | |
RED := \033[31m | |
GREEN := \033[32m | |
YELLOW := \033[33m | |
BLUE := \033[34m | |
MAGENTA := \033[35m | |
CYAN := \033[36m | |
RESET := \033[0m | |
help: ## Show this help message | |
@echo "$(CYAN)CloudBridge DevOps Platform$(RESET)" | |
@echo "$(YELLOW)Available commands:$(RESET)" | |
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf " $(GREEN)%-20s$(RESET) %s\n", $$1, $$2}' $(MAKEFILE_LIST) | |
# ============================================================================== | |
# Setup Commands | |
# ============================================================================== | |
setup: ## Set up the complete project structure and dependencies | |
@echo "$(BLUE)Setting up CloudBridge project structure...$(RESET)" | |
@$(MAKE) create-structure | |
@$(MAKE) install-tools | |
@$(MAKE) init-modules | |
@echo "$(GREEN)✅ Project setup complete!$(RESET)" | |
create-structure: ## Create the complete directory structure | |
@echo "$(YELLOW)Creating project structure...$(RESET)" | |
# Root directories | |
@mkdir -p {backend,frontend,proto,infrastructure,docs,scripts,deployments} | |
# Backend service directories | |
@mkdir -p backend/{api-gateway,deployment-service,monitoring-service,auth-service,notification-service,scaling-service,containerization-service,code-intelligence-service,shared} | |
# Backend subdirectories for each service | |
@for service in api-gateway deployment-service monitoring-service auth-service notification-service scaling-service containerization-service code-intelligence-service; do \ | |
mkdir -p backend/$$service/{cmd,internal/{handler,service,repository,config},pkg,test,migrations}; \ | |
done | |
# Shared backend directories | |
@mkdir -p backend/shared/{auth,config,database,logger,metrics,middleware,types,utils} | |
# Frontend directories | |
@mkdir -p frontend/src/{components/{common,deployment,monitoring,environment,code-intelligence,scaling,onboarding},composables,stores,services,generated,views,router,utils,assets} | |
@mkdir -p frontend/{public,scripts,tests/{unit,integration,e2e}} | |
# Protocol Buffer directories | |
@mkdir -p proto/{common/v1,deployment/v1,monitoring/v1,auth/v1,scaling/v1,containerization/v1,code_intelligence/v1,notification/v1} | |
# Infrastructure directories | |
@mkdir -p infrastructure/{kubernetes/{base,overlays/{dev,staging,prod}},terraform/{modules,environments/{dev,staging,prod}},docker,helm} | |
# Documentation directories | |
@mkdir -p docs/{api,architecture,deployment,user-guide} | |
# Scripts directory | |
@mkdir -p scripts/{build,deploy,dev,migration} | |
# Deployments directory | |
@mkdir -p deployments/{local,dev,staging,prod} | |
@echo "$(GREEN)✅ Directory structure created$(RESET)" | |
install-tools: ## Install required development tools | |
@echo "$(YELLOW)Installing development tools...$(RESET)" | |
# Check if Go is installed | |
@if ! command -v go >/dev/null 2>&1; then \ | |
echo "$(RED)❌ Go is not installed. Please install Go $(GO_VERSION)$(RESET)"; \ | |
exit 1; \ | |
fi | |
# Check if Node.js is installed | |
@if ! command -v node >/dev/null 2>&1; then \ | |
echo "$(RED)❌ Node.js is not installed. Please install Node.js $(NODE_VERSION)$(RESET)"; \ | |
exit 1; \ | |
fi | |
# Install Go tools | |
@echo "Installing Go tools..." | |
@go install google.golang.org/protobuf/cmd/protoc-gen-go@latest | |
@go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest | |
@go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest | |
@go install github.com/golang-migrate/migrate/v4/cmd/migrate@latest | |
@go install github.com/air-verse/air@latest | |
# Install buf for Protocol Buffers | |
@if ! command -v buf >/dev/null 2>&1; then \ | |
echo "Installing buf v$(BUF_VERSION)..."; \ | |
echo "$(CYAN)💡 Check for latest version at: https://github.com/bufbuild/buf/releases$(RESET)"; \ | |
curl -sSL "https://github.com/bufbuild/buf/releases/download/v$(BUF_VERSION)/buf-$(shell uname -s)-$(shell uname -m)" -o /tmp/buf; \ | |
chmod +x /tmp/buf; \ | |
sudo mv /tmp/buf /usr/local/bin/buf; \ | |
else \ | |
echo "✅ buf already installed: $(buf --version)"; \ | |
fi | |
# Install protoc if not present | |
@if ! command -v protoc >/dev/null 2>&1; then \ | |
echo "Installing protoc v$(PROTO_VERSION)..."; \ | |
echo "$(CYAN)💡 Check for latest version at: https://github.com/protocolbuffers/protobuf/releases$(RESET)"; \ | |
curl -sSL "https://github.com/protocolbuffers/protobuf/releases/download/v$(PROTO_VERSION)/protoc-$(PROTO_VERSION)-$(shell uname -s)-$(shell uname -m).zip" -o /tmp/protoc.zip; \ | |
sudo unzip -o /tmp/protoc.zip -d /usr/local bin/protoc; \ | |
sudo unzip -o /tmp/protoc.zip -d /usr/local 'include/*'; \ | |
rm /tmp/protoc.zip; \ | |
else \ | |
echo "✅ protoc already installed: $(protoc --version)"; \ | |
fi | |
@echo "$(GREEN)✅ Development tools installed$(RESET)" | |
check-versions: ## Check installed tool versions | |
@echo "$(CYAN)Installed Tool Versions:$(RESET)" | |
@echo "" | |
@echo "$(YELLOW)Core Tools:$(RESET)" | |
@go version 2>/dev/null || echo "❌ Go not installed" | |
@node --version 2>/dev/null | sed 's/^/Node.js /' || echo "❌ Node.js not installed" | |
@echo "" | |
@echo "$(YELLOW)Protocol Buffer Tools:$(RESET)" | |
@protoc --version 2>/dev/null || echo "❌ protoc not installed" | |
@buf --version 2>/dev/null || echo "❌ buf not installed" | |
@echo "" | |
@echo "$(YELLOW)Go Development Tools:$(RESET)" | |
@go version -m $(which protoc-gen-go) 2>/dev/null | grep mod | head -1 || echo "❌ protoc-gen-go not installed" | |
@go version -m $(which protoc-gen-go-grpc) 2>/dev/null | grep mod | head -1 || echo "❌ protoc-gen-go-grpc not installed" | |
@golangci-lint version 2>/dev/null || echo "❌ golangci-lint not installed" | |
@migrate -version 2>/dev/null || echo "❌ migrate not installed" | |
debug-distro: ## Debug Linux distribution detection | |
@echo "$(CYAN)Linux Distribution Detection Debug$(RESET)" | |
@echo "" | |
@if [ "$(OS)" != "linux" ]; then \ | |
echo "$(YELLOW)Not running on Linux (detected: $(OS))$(RESET)"; \ | |
exit 0; \ | |
fi | |
@echo "$(YELLOW)Distribution Detection Process:$(RESET)" | |
@echo " Detected Distribution: $(DISTRO)" | |
@echo "" | |
@echo "$(YELLOW)Available Detection Files:$(RESET)" | |
@if [ -f /etc/os-release ]; then \ | |
echo " ✅ /etc/os-release found"; \ | |
echo " ID: $(. /etc/os-release && echo $ID 2>/dev/null || echo 'not found')"; \ | |
echo " NAME: $(. /etc/os-release && echo $NAME 2>/dev/null || echo 'not found')"; \ | |
echo " VERSION: $(. /etc/os-release && echo $VERSION 2>/dev/null || echo 'not found')"; \ | |
else \ | |
echo " ❌ /etc/os-release not found"; \ | |
fi | |
@if [ -f /etc/debian_version ]; then \ | |
echo " ✅ /etc/debian_version found: $(cat /etc/debian_version)"; \ | |
else \ | |
echo " ❌ /etc/debian_version not found"; \ | |
fi | |
@if [ -f /etc/redhat-release ]; then \ | |
echo " ✅ /etc/redhat-release found: $(cat /etc/redhat-release)"; \ | |
else \ | |
echo " ❌ /etc/redhat-release not found"; \ | |
fi | |
@echo "" | |
@echo "$(YELLOW)Available Package Managers:$(RESET)" | |
@command -v apt-get >/dev/null 2>&1 && echo " ✅ apt-get" || echo " ❌ apt-get" | |
@command -v dnf >/dev/null 2>&1 && echo " ✅ dnf" || echo " ❌ dnf" | |
@command -v yum >/dev/null 2>&1 && echo " ✅ yum" || echo " ❌ yum" | |
@command -v pacman >/dev/null 2>&1 && echo " ✅ pacman" || echo " ❌ pacman" | |
@command -v zypper >/dev/null 2>&1 && echo " ✅ zypper" || echo " ❌ zypper" | |
@command -v apk >/dev/null 2>&1 && echo " ✅ apk" || echo " ❌ apk" | |
@echo "" | |
@echo "$(YELLOW)Recommended Install Command:$(RESET)" | |
@echo " $(INSTALL_CMD)" | |
@if [ "$(DISTRO)" = "unknown" ]; then \ | |
echo ""; \ | |
echo "$(RED)⚠️ Unknown distribution detected!$(RESET)"; \ | |
echo "$(CYAN)Please manually install: curl, unzip, git, build tools$(RESET)"; \ | |
fi | |
@echo "" | |
@echo "$(CYAN)💡 To check for latest versions:$(RESET)" | |
@echo " - Protocol Buffers: https://github.com/protocolbuffers/protobuf/releases" | |
@echo " - Buf: https://github.com/bufbuild/buf/releases" | |
@echo " - Go tools: Use 'go install tool@latest'" | |
init-modules: ## Initialize Go modules and Node.js dependencies | |
@echo "$(YELLOW)Initializing modules...$(RESET)" | |
# Initialize Go modules for each service | |
@for service in api-gateway deployment-service monitoring-service auth-service notification-service scaling-service containerization-service code-intelligence-service shared; do \ | |
echo "Initializing Go module for $service..."; \ | |
cd backend/$service && go mod init github.com/cloudbridge/$service && cd ../..; \ | |
done | |
# Initialize frontend package.json | |
@cd frontend && npm init -y | |
# Install Vue.js core dependencies | |
@cd frontend && npm install vue@^3.4.0 @vitejs/plugin-vue typescript vue-tsc vite vuetify@^3.0.0 pinia vue-router@4 @types/node | |
# Install development dependencies including prettier and eslint | |
@cd frontend && npm install -D \ | |
@typescript-eslint/eslint-plugin@^6.0.0 \ | |
@typescript-eslint/parser@^6.0.0 \ | |
eslint@^8.45.0 \ | |
eslint-plugin-vue@^9.15.0 \ | |
eslint-config-prettier@^9.0.0 \ | |
eslint-plugin-prettier@^5.0.0 \ | |
prettier@^3.0.0 \ | |
vitest@^1.0.0 \ | |
@vue/test-utils@^2.4.0 \ | |
happy-dom@^12.0.0 \ | |
playwright@^1.40.0 | |
@echo "$(GREEN)✅ Modules initialized$(RESET)" | |
# ============================================================================== | |
# Protocol Buffer Commands | |
# ============================================================================== | |
proto: proto-generate ## Generate Protocol Buffer code for all languages | |
proto-generate: proto-clean proto-go proto-web proto-docs ## Generate Protocol Buffer code | |
@echo "$(GREEN)✅ Protocol Buffer generation complete$(RESET)" | |
proto-clean: ## Clean generated Protocol Buffer files | |
@echo "$(YELLOW)Cleaning generated proto files...$(RESET)" | |
@find backend -name "*.pb.go" -delete || true | |
@find backend -name "*_grpc.pb.go" -delete || true | |
@rm -rf frontend/src/generated/* || true | |
proto-go: ## Generate Go Protocol Buffer code | |
@echo "$(YELLOW)Generating Go proto files...$(RESET)" | |
@mkdir -p backend/shared/proto | |
@buf generate --template buf.gen.go.yaml | |
# Copy generated files to each service | |
@for service in deployment monitoring auth scaling containerization code_intelligence notification; do \ | |
mkdir -p backend/$$service-service/pkg/proto; \ | |
cp -r backend/shared/proto/$$service backend/$$service-service/pkg/proto/; \ | |
done | |
proto-web: ## Generate TypeScript/gRPC-Web code | |
@echo "$(YELLOW)Generating TypeScript proto files...$(RESET)" | |
@mkdir -p frontend/src/generated | |
@buf generate --template buf.gen.web.yaml | |
proto-docs: ## Generate Protocol Buffer documentation | |
@echo "$(YELLOW)Generating proto documentation...$(RESET)" | |
@mkdir -p docs/api | |
@buf generate --template buf.gen.docs.yaml | |
proto-lint: ## Lint Protocol Buffer files | |
@echo "$(YELLOW)Linting proto files...$(RESET)" | |
@if find proto -name "*.proto" 2>/dev/null | grep -q .; then \ | |
buf lint; \ | |
else \ | |
echo "📝 No proto files found, skipping proto linting..."; \ | |
fi | |
proto-breaking: ## Check for breaking changes in Protocol Buffers | |
@echo "$(YELLOW)Checking for proto breaking changes...$(RESET)" | |
@buf breaking --against '.git#branch=main' | |
# ============================================================================== | |
# Backend Commands | |
# ============================================================================== | |
backend: backend-build ## Build all backend services | |
backend-build: proto-go ## Build all Go services | |
@echo "$(YELLOW)Building backend services...$(RESET)" | |
@for service in api-gateway deployment-service monitoring-service auth-service notification-service scaling-service containerization-service code-intelligence-service; do \ | |
echo "Building $$service..."; \ | |
cd backend/$$service && go build -o bin/$$service ./cmd && cd ../..; \ | |
done | |
@echo "$(GREEN)✅ Backend services built$(RESET)" | |
backend-deps: ## Download backend dependencies | |
@echo "$(YELLOW)Downloading Go dependencies...$(RESET)" | |
@for service in api-gateway deployment-service monitoring-service auth-service notification-service scaling-service containerization-service code-intelligence-service; do \ | |
echo "Getting dependencies for $$service..."; \ | |
cd backend/$$service && go mod tidy && cd ../..; \ | |
done | |
backend-test: ## Run backend tests | |
@echo "$(YELLOW)Running backend tests...$(RESET)" | |
@for service in api-gateway deployment-service monitoring-service auth-service notification-service scaling-service containerization-service code-intelligence-service; do \ | |
if [ -d "backend/$service" ]; then \ | |
echo "Testing $service..."; \ | |
cd backend/$service; \ | |
if find . -name "*_test.go" | grep -q .; then \ | |
go test ./... -v; \ | |
else \ | |
echo "📝 No tests found for $service, skipping..."; \ | |
fi; \ | |
cd ../..; \ | |
else \ | |
echo "📝 Service $service not found, skipping..."; \ | |
fi; \ | |
done | |
@echo "$(GREEN)✅ Backend tests completed$(RESET)" | |
backend-lint: ## Lint backend code | |
@echo "$(YELLOW)Linting backend code...$(RESET)" | |
@for service in api-gateway deployment-service monitoring-service auth-service notification-service scaling-service containerization-service code-intelligence-service; do \ | |
if [ -d "backend/$service" ]; then \ | |
echo "Linting $service..."; \ | |
cd backend/$service; \ | |
if find . -name "*.go" -not -path "./vendor/*" | grep -q .; then \ | |
golangci-lint run || echo "⚠️ Linting issues found in $service"; \ | |
else \ | |
echo "📝 No Go files found in $service, skipping..."; \ | |
fi; \ | |
cd ../..; \ | |
else \ | |
echo "📝 Service $service not found, skipping..."; \ | |
fi; \ | |
done | |
@echo "$(GREEN)✅ Backend linting completed$(RESET)" | |
# ============================================================================== | |
# Frontend Commands | |
# ============================================================================== | |
frontend: frontend-build ## Build frontend application | |
frontend-install: ## Install frontend dependencies | |
@echo "$(YELLOW)Installing frontend dependencies...$(RESET)" | |
@cd frontend && npm install | |
frontend-build: proto-web frontend-install ## Build frontend application | |
@echo "$(YELLOW)Building frontend application...$(RESET)" | |
@cd frontend && npm run build | |
frontend-dev: proto-web frontend-install ## Start frontend development server | |
@echo "$(YELLOW)Starting frontend development server...$(RESET)" | |
@cd frontend && npm run dev | |
frontend-test: ## Run frontend tests | |
@echo "$(YELLOW)Running frontend tests...$(RESET)" | |
@cd frontend && npm run test | |
frontend-test-e2e: ## Run end-to-end tests | |
@echo "$(YELLOW)Running E2E tests...$(RESET)" | |
@cd frontend && npm run test:e2e | |
frontend-lint: ## Lint frontend code | |
@echo "$(YELLOW)Linting frontend code...$(RESET)" | |
@cd frontend && npm run lint | |
frontend-type-check: ## Run TypeScript type checking | |
@echo "$(YELLOW)Running TypeScript type checking...$(RESET)" | |
@cd frontend && npm run type-check | |
# ============================================================================== | |
# Docker Commands | |
# ============================================================================== | |
docker-build: ## Build all Docker images | |
@echo "$(YELLOW)Building Docker images...$(RESET)" | |
@for service in api-gateway deployment-service monitoring-service auth-service notification-service scaling-service containerization-service code-intelligence-service; do \ | |
echo "Building Docker image for $$service..."; \ | |
docker build -t $(DOCKER_REGISTRY)/$$service:latest -f backend/$$service/Dockerfile backend/$$service; \ | |
done | |
@docker build -t $(DOCKER_REGISTRY)/frontend:latest -f frontend/Dockerfile frontend | |
@echo "$(GREEN)✅ Docker images built$(RESET)" | |
docker-push: docker-build ## Push Docker images to registry | |
@echo "$(YELLOW)Pushing Docker images...$(RESET)" | |
@for service in api-gateway deployment-service monitoring-service auth-service notification-service scaling-service containerization-service code-intelligence-service frontend; do \ | |
echo "Pushing $$service..."; \ | |
docker push $(DOCKER_REGISTRY)/$$service:latest; \ | |
done | |
# ============================================================================== | |
# Development Environment | |
# ============================================================================== | |
dev-up: ## Start development environment | |
@echo "$(YELLOW)Starting development environment...$(RESET)" | |
@docker-compose -f deployments/local/docker-compose.yml up -d | |
@echo "$(GREEN)✅ Development environment started$(RESET)" | |
@echo "$(CYAN)Services available at:$(RESET)" | |
@echo " - PostgreSQL: localhost:5432" | |
@echo " - Redis: localhost:6379" | |
@echo " - NATS: localhost:4222" | |
@echo " - Prometheus: localhost:9090" | |
@echo " - Grafana: localhost:3000" | |
dev-down: ## Stop development environment | |
@echo "$(YELLOW)Stopping development environment...$(RESET)" | |
@docker-compose -f deployments/local/docker-compose.yml down | |
@echo "$(GREEN)✅ Development environment stopped$(RESET)" | |
dev-logs: ## Show development environment logs | |
@docker-compose -f deployments/local/docker-compose.yml logs -f | |
dev-clean: ## Clean development environment | |
@echo "$(YELLOW)Cleaning development environment...$(RESET)" | |
@docker-compose -f deployments/local/docker-compose.yml down -v | |
@docker system prune -f | |
@echo "$(GREEN)✅ Development environment cleaned$(RESET)" | |
# ============================================================================== | |
# Database Commands | |
# ============================================================================== | |
migrate-create: ## Create a new database migration (usage: make migrate-create NAME=create_users) | |
@if [ -z "$(NAME)" ]; then \ | |
echo "$(RED)❌ NAME is required. Usage: make migrate-create NAME=create_users$(RESET)"; \ | |
exit 1; \ | |
fi | |
@echo "$(YELLOW)Creating migration: $(NAME)$(RESET)" | |
@migrate create -ext sql -dir backend/shared/migrations -seq $(NAME) | |
migrate-up: ## Run database migrations | |
@echo "$(YELLOW)Running database migrations...$(RESET)" | |
@migrate -path backend/shared/migrations -database "postgresql://cloudbridge:cloudbridge@localhost:5432/cloudbridge?sslmode=disable" up | |
migrate-down: ## Rollback database migrations | |
@echo "$(YELLOW)Rolling back database migrations...$(RESET)" | |
@migrate -path backend/shared/migrations -database "postgresql://cloudbridge:cloudbridge@localhost:5432/cloudbridge?sslmode=disable" down 1 | |
migrate-force: ## Force migration version (usage: make migrate-force VERSION=1) | |
@if [ -z "$(VERSION)" ]; then \ | |
echo "$(RED)❌ VERSION is required. Usage: make migrate-force VERSION=1$(RESET)"; \ | |
exit 1; \ | |
fi | |
@migrate -path backend/shared/migrations -database "postgresql://cloudbridge:cloudbridge@localhost:5432/cloudbridge?sslmode=disable" force $(VERSION) | |
# ============================================================================== | |
# Testing Commands | |
# ============================================================================== | |
test: test-unit test-integration ## Run all tests | |
test-unit: backend-test frontend-test ## Run unit tests | |
test-integration: ## Run integration tests | |
@echo "$(YELLOW)Running integration tests...$(RESET)" | |
@cd backend && go test ./test/integration/... -v | |
test-coverage: ## Generate test coverage reports | |
@echo "$(YELLOW)Generating test coverage...$(RESET)" | |
@mkdir -p coverage | |
@for service in api-gateway deployment-service monitoring-service auth-service notification-service scaling-service containerization-service code-intelligence-service; do \ | |
echo "Coverage for $$service..."; \ | |
cd backend/$$service && go test ./... -coverprofile=../../coverage/$$service.out && cd ../..; \ | |
done | |
@cd frontend && npm run coverage | |
# ============================================================================== | |
# Linting and Formatting | |
# ============================================================================== | |
lint: backend-lint frontend-lint proto-lint ## Run all linters | |
format: format-go format-frontend format-proto ## Format all code | |
format-go: ## Format Go code | |
@echo "$(YELLOW)Formatting Go code...$(RESET)" | |
@for service in api-gateway deployment-service monitoring-service auth-service notification-service scaling-service containerization-service code-intelligence-service shared; do \ | |
echo "Formatting $$service..."; \ | |
cd backend/$$service && go fmt ./... && cd ../..; \ | |
done | |
format-frontend: ## Format frontend code | |
@echo "$(YELLOW)Formatting frontend code...$(RESET)" | |
@if [ -f "frontend/package.json" ] && [ -d "frontend/src" ]; then \ | |
cd frontend; \ | |
if npm run --silent format >/dev/null 2>&1; then \ | |
npm run format; \ | |
else \ | |
echo "📝 No format script found in package.json, skipping frontend formatting..."; \ | |
fi; \ | |
else \ | |
echo "📝 Frontend not initialized, skipping formatting..."; \ | |
fi | |
format-proto: ## Format Protocol Buffer files | |
@echo "$(YELLOW)Formatting proto files...$(RESET)" | |
@buf format -w | |
# ============================================================================== | |
# Deployment Commands | |
# ============================================================================== | |
deploy-dev: ## Deploy to development environment | |
@echo "$(YELLOW)Deploying to development...$(RESET)" | |
@kubectl apply -k infrastructure/kubernetes/overlays/dev | |
@echo "$(GREEN)✅ Deployed to development$(RESET)" | |
deploy-staging: ## Deploy to staging environment | |
@echo "$(YELLOW)Deploying to staging...$(RESET)" | |
@kubectl apply -k infrastructure/kubernetes/overlays/staging | |
@echo "$(GREEN)✅ Deployed to staging$(RESET)" | |
deploy-prod: ## Deploy to production environment | |
@echo "$(YELLOW)Deploying to production...$(RESET)" | |
@kubectl apply -k infrastructure/kubernetes/overlays/prod | |
@echo "$(GREEN)✅ Deployed to production$(RESET)" | |
# ============================================================================== | |
# Configuration Files | |
# ============================================================================== | |
create-configs: ## Create configuration files | |
@echo "$(YELLOW)Creating configuration files...$(RESET)" | |
@$(MAKE) create-buf-configs | |
@$(MAKE) create-docker-configs | |
@$(MAKE) create-frontend-configs | |
@$(MAKE) create-k8s-configs | |
@echo "$(GREEN)✅ Configuration files created$(RESET)" | |
create-buf-configs: ## Create buf configuration files | |
@echo "Creating buf configuration..." | |
# buf.yaml | |
@cat > buf.yaml << 'EOF' | |
version: v1 | |
deps: | |
- buf.build/googleapis/googleapis | |
lint: | |
use: | |
- DEFAULT | |
except: | |
- UNARY_RPC | |
breaking: | |
use: | |
- FILE | |
modules: | |
- path: proto | |
EOF | |
# buf.gen.go.yaml | |
@cat > buf.gen.go.yaml << 'EOF' | |
version: v1 | |
plugins: | |
- plugin: buf.build/protocolbuffers/go | |
out: backend/shared/proto | |
opt: paths=source_relative | |
- plugin: buf.build/grpc/go | |
out: backend/shared/proto | |
opt: paths=source_relative | |
EOF | |
# buf.gen.web.yaml | |
@cat > buf.gen.web.yaml << 'EOF' | |
version: v1 | |
plugins: | |
- plugin: buf.build/protocolbuffers/js | |
out: frontend/src/generated | |
opt: | |
- import_style=commonjs | |
- binary | |
- plugin: buf.build/grpc/web | |
out: frontend/src/generated | |
opt: | |
- import_style=commonjs+dts | |
- mode=grpcwebtext | |
EOF | |
# buf.gen.docs.yaml | |
@cat > buf.gen.docs.yaml << 'EOF' | |
version: v1 | |
plugins: | |
- plugin: buf.build/bufbuild/docs | |
out: docs/api | |
EOF | |
create-docker-configs: ## Create Docker configuration files | |
@echo "Creating Docker configurations..." | |
# Development docker-compose.yml | |
@mkdir -p deployments/local | |
@cat > deployments/local/docker-compose.yml << 'EOF' | |
services: | |
postgres: | |
image: postgres:15 | |
environment: | |
POSTGRES_DB: cloudbridge | |
POSTGRES_USER: cloudbridge | |
POSTGRES_PASSWORD: cloudbridge | |
ports: | |
- 5432:5432 | |
volumes: | |
- postgres_data:/var/lib/postgresql/data | |
redis: | |
image: redis:7-alpine | |
ports: | |
- 6379:6379 | |
volumes: | |
- redis_data:/data | |
nats: | |
image: nats:2.10-alpine | |
ports: | |
- 4222:4222 | |
- 8222:8222 | |
command: ["-js", "-m", "8222"] | |
prometheus: | |
image: prom/prometheus:latest | |
ports: | |
- 9090:9090 | |
volumes: | |
- ./prometheus.yml:/etc/prometheus/prometheus.yml | |
- prometheus_data:/prometheus | |
grafana: | |
image: grafana/grafana:latest | |
ports: | |
- 3000:3000 | |
environment: | |
GF_SECURITY_ADMIN_PASSWORD: admin | |
volumes: | |
- grafana_data:/var/lib/grafana | |
volumes: | |
postgres_data: | |
redis_data: | |
prometheus_data: | |
grafana_data: | |
EOF | |
create-frontend-configs: ## Create frontend configuration files | |
@echo "Creating frontend configurations..." | |
# package.json scripts | |
@cd frontend && npm pkg set scripts.dev="vite" | |
@cd frontend && npm pkg set scripts.build="vue-tsc && vite build" | |
@cd frontend && npm pkg set scripts.preview="vite preview" | |
@cd frontend && npm pkg set scripts.test="vitest" | |
@cd frontend && npm pkg set scripts.test:e2e="playwright test" | |
@cd frontend && npm pkg set scripts.lint="eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix" | |
@cd frontend && npm pkg set scripts.type-check="vue-tsc --noEmit" | |
@cd frontend && npm pkg set scripts.format="prettier --write src/" | |
@cd frontend && npm pkg set scripts.coverage="vitest --coverage" | |
@cd frontend && npm pkg set scripts.lint:check="eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts" | |
@cd frontend && npm pkg set scripts.format:check="prettier --check src/" | |
# prettier configuration | |
@cat > frontend/.prettierrc << 'EOF' | |
{ | |
"arrowParens": "always", | |
"bracketSameLine": false, | |
"bracketSpacing": true, | |
"embeddedLanguageFormatting": "auto", | |
"htmlWhitespaceSensitivity": "css", | |
"insertPragma": false, | |
"jsxSingleQuote": false, | |
"printWidth": 80, | |
"proseWrap": "preserve", | |
"quoteProps": "as-needed", | |
"requirePragma": false, | |
"semi": false, | |
"singleQuote": true, | |
"tabWidth": 2, | |
"trailingComma": "none", | |
"useTabs": false, | |
"vueIndentScriptAndStyle": true | |
} | |
EOF | |
# eslint configuration (compatible with prettier) | |
@cat > frontend/.eslintrc.cjs << 'EOF' | |
module.exports = { | |
root: true, | |
env: { | |
node: true, | |
'vue/setup-compiler-macros': true | |
}, | |
extends: [ | |
'plugin:vue/vue3-essential', | |
'@vue/eslint-config-typescript', | |
'@vue/eslint-config-prettier/skip-formatting' | |
], | |
parserOptions: { | |
ecmaVersion: 'latest' | |
}, | |
rules: { | |
'vue/multi-word-component-names': 'off', | |
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }], | |
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off', | |
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off' | |
} | |
} | |
EOF | |
# prettier ignore file | |
@cat > frontend/.prettierignore << 'EOF' | |
dist/ | |
node_modules/ | |
coverage/ | |
*.md | |
public/ | |
src/generated/ | |
EOF | |
# vite.config.ts | |
@cat > frontend/vite.config.ts << 'EOF' | |
import { defineConfig } from 'vite' | |
import vue from '@vitejs/plugin-vue' | |
import { resolve } from 'path' | |
export default defineConfig({ | |
plugins: [vue()], | |
resolve: { | |
alias: { | |
'@': resolve(__dirname, 'src'), | |
}, | |
}, | |
server: { | |
port: 3000, | |
proxy: { | |
'/api': { | |
target: 'http://localhost:8080', | |
changeOrigin: true, | |
}, | |
}, | |
}, | |
build: { | |
target: 'esnext', | |
sourcemap: true, | |
}, | |
}) | |
EOF | |
# tsconfig.json | |
@cat > frontend/tsconfig.json << 'EOF' | |
{ | |
"compilerOptions": { | |
"target": "esnext", | |
"module": "esnext", | |
"moduleResolution": "bundler", | |
"strict": true, | |
"jsx": "preserve", | |
"esModuleInterop": true, | |
"skipLibCheck": true, | |
"forceConsistentCasingInFileNames": true, | |
"allowImportingTsExtensions": true, | |
"noEmit": true, | |
"baseUrl": ".", | |
"paths": { | |
"@/*": ["src/*"] | |
} | |
}, | |
"include": [ | |
"src/**/*.ts", | |
"src/**/*.vue" | |
], | |
"exclude": [ | |
"node_modules", | |
"dist" | |
] | |
} | |
EOF | |
create-k8s-configs: ## Create Kubernetes configuration files | |
@echo "Creating Kubernetes configurations..." | |
@mkdir -p infrastructure/kubernetes/base | |
# kustomization.yaml | |
@cat > infrastructure/kubernetes/base/kustomization.yaml << 'EOF' | |
apiVersion: kustomize.config.k8s.io/v1beta1 | |
kind: Kustomization | |
resources: | |
- namespace.yaml | |
- postgres.yaml | |
- redis.yaml | |
- nats.yaml | |
- api-gateway.yaml | |
- deployment-service.yaml | |
- monitoring-service.yaml | |
- auth-service.yaml | |
- notification-service.yaml | |
- scaling-service.yaml | |
- containerization-service.yaml | |
- code-intelligence-service.yaml | |
- frontend.yaml | |
commonLabels: | |
app.kubernetes.io/name: cloudbridge | |
app.kubernetes.io/part-of: cloudbridge-platform | |
EOF | |
# ============================================================================== | |
# Cleanup Commands | |
# ============================================================================== | |
clean: clean-build clean-deps clean-generated ## Clean all generated files | |
clean-build: ## Clean build artifacts | |
@echo "$(YELLOW)Cleaning build artifacts...$(RESET)" | |
@find backend -name "bin" -type d -exec rm -rf {} + 2>/dev/null || true | |
@rm -rf frontend/dist frontend/node_modules/.vite 2>/dev/null || true | |
clean-deps: ## Clean dependencies | |
@echo "$(YELLOW)Cleaning dependencies...$(RESET)" | |
@rm -rf frontend/node_modules 2>/dev/null || true | |
@for service in api-gateway deployment-service monitoring-service auth-service notification-service scaling-service containerization-service code-intelligence-service shared; do \ | |
cd backend/$$service && go clean -modcache && cd ../..; \ | |
done 2>/dev/null || true | |
clean-generated: proto-clean ## Clean generated files | |
@echo "$(YELLOW)Cleaning generated files...$(RESET)" | |
@rm -rf docs/api/* 2>/dev/null || true | |
# ============================================================================== | |
# Utility Commands | |
# ============================================================================== | |
status: ## Show project status | |
@echo "$(CYAN)CloudBridge Project Status$(RESET)" | |
@echo "" | |
@echo "$(YELLOW)Go Services:$(RESET)" | |
@for service in api-gateway deployment-service monitoring-service auth-service notification-service scaling-service containerization-service code-intelligence-service; do \ | |
if [ -f "backend/$service/go.mod" ]; then \ | |
echo " ✅ $service"; \ | |
else \ | |
echo " ❌ $service"; \ | |
fi; \ | |
done | |
@echo "" | |
@echo "$(YELLOW)Frontend:$(RESET)" | |
@if [ -f "frontend/package.json" ]; then \ | |
echo " ✅ Vue.js application"; \ | |
else \ | |
echo " ❌ Vue.js application"; \ | |
fi | |
@echo "" | |
@echo "$(YELLOW)Protocol Buffers:$(RESET)" | |
@if [ -f "buf.yaml" ]; then \ | |
echo " ✅ Buf configuration"; \ | |
else \ | |
echo " ❌ Buf configuration"; \ | |
fi | |
@echo "" | |
@echo "$(CYAN)💡 Run 'make check-versions' to see installed tool versions$(RESET)" | |
verify-setup: ## Verify that all tools are properly installed and configured | |
@echo "$(CYAN)Verifying CloudBridge Development Setup$(RESET)" | |
@echo "" | |
# Check system detection | |
@echo "$(YELLOW)✓ System Detection:$(RESET)" | |
@echo " Platform: $(OS)-$(ARCH)" | |
@echo " Protoc Architecture: $(PROTOC_ARCH)" | |
@echo "" | |
# Check required tools | |
@echo "$(YELLOW)Required Tools:$(RESET)" | |
@if command -v go >/dev/null 2>&1; then \ | |
echo " ✅ Go: $(go version | cut -d' ' -f3)"; \ | |
else \ | |
echo " ❌ Go: Not installed"; \ | |
fi | |
@if command -v node >/dev/null 2>&1; then \ | |
CURRENT_NODE=$(node --version); \ | |
if [ "$CURRENT_NODE" = "v$(NODE_VERSION)" ]; then \ | |
echo " ✅ Node.js: $CURRENT_NODE (matches required v$(NODE_VERSION))"; \ | |
else \ | |
echo " ⚠️ Node.js: $CURRENT_NODE (required: v$(NODE_VERSION))"; \ | |
fi; \ | |
else \ | |
echo " ❌ Node.js: Not installed"; \ | |
fi | |
@if command -v protoc >/dev/null 2>&1; then \ | |
CURRENT_PROTOC=$(protoc --version | grep -o '[0-9]\+\.[0-9]\+' || echo "unknown"); \ | |
if [ "$CURRENT_PROTOC" = "$(PROTO_VERSION)" ]; then \ | |
echo " ✅ protoc: $CURRENT_PROTOC (matches required $(PROTO_VERSION))"; \ | |
else \ | |
echo " ⚠️ protoc: $CURRENT_PROTOC (required: $(PROTO_VERSION))"; \ | |
fi; \ | |
else \ | |
echo " ❌ protoc: Not installed"; \ | |
fi | |
@if command -v buf >/dev/null 2>&1; then \ | |
echo " ✅ buf: $(buf --version)"; \ | |
else \ | |
echo " ❌ buf: Not installed"; \ | |
fi | |
@echo "" | |
@echo "$(YELLOW)Go Protocol Buffer Tools:$(RESET)" | |
@if command -v protoc-gen-go >/dev/null 2>&1; then \ | |
echo " ✅ protoc-gen-go: installed"; \ | |
else \ | |
echo " ❌ protoc-gen-go: Not installed"; \ | |
fi | |
@if command -v protoc-gen-go-grpc >/dev/null 2>&1; then \ | |
echo " ✅ protoc-gen-go-grpc: installed"; \ | |
else \ | |
echo " ❌ protoc-gen-go-grpc: Not installed"; \ | |
fi | |
@echo "" | |
@if [ -f "buf.yaml" ] && [ -f "frontend/package.json" ]; then \ | |
echo "$(GREEN)🎉 CloudBridge setup verification complete!$(RESET)"; \ | |
echo "$(CYAN)Ready to run: make dev-up && make backend && make frontend-dev$(RESET)"; \ | |
else \ | |
echo "$(YELLOW)⚠️ Project not fully initialized. Run: make init$(RESET)"; \ | |
fi | |
logs: ## Show service logs in development | |
@echo "$(YELLOW)Showing service logs...$(RESET)" | |
@docker-compose -f deployments/local/docker-compose.yml logs -f --tail=100 | |
restart: dev-down dev-up ## Restart development environment | |
# ============================================================================== | |
# Full Project Initialization | |
# ============================================================================== | |
init: ## Initialize complete CloudBridge project | |
@echo "$(BLUE)🚀 Initializing CloudBridge DevOps Platform...$(RESET)" | |
@$(MAKE) setup | |
@$(MAKE) create-configs | |
@$(MAKE) proto | |
@$(MAKE) backend-deps | |
@$(MAKE) frontend-install | |
@echo "" | |
@echo "$(GREEN)🎉 CloudBridge project initialized successfully!$(RESET)" | |
@echo "" | |
@echo "$(CYAN)System Information:$(RESET)" | |
@echo " Platform: $(OS)-$(ARCH)" | |
@echo " Distribution: $(DISTRO)" | |
@echo " Node.js: $(NODE_VERSION)" | |
@echo " Protocol Buffers: $(PROTO_VERSION)" | |
@echo "" | |
@echo "$(CYAN)Next steps:$(RESET)" | |
@echo " 1. Verify setup: $(YELLOW)make verify-setup$(RESET)" | |
@echo " 2. Start development environment: $(YELLOW)make dev-up$(RESET)" | |
@echo " 3. Build backend services: $(YELLOW)make backend$(RESET)" | |
@echo " 4. Start frontend development: $(YELLOW)make frontend-dev$(RESET)" | |
@echo "" | |
@echo "$(CYAN)Quality Assurance:$(RESET)" | |
@echo " - Run linting: $(YELLOW)make lint$(RESET)" | |
@echo " - Format code: $(YELLOW)make format$(RESET)" | |
@echo " - Run all tests: $(YELLOW)make test$(RESET)" | |
@echo " - Check versions: $(YELLOW)make check-versions$(RESET)" | |
@echo "" | |
@echo "$(CYAN)Useful commands:$(RESET)" | |
@echo " - $(YELLOW)make help$(RESET) - Show available commands" | |
@echo " - $(YELLOW)make status$(RESET) - Check project status" | |
@echo " - $(YELLOW)make logs$(RESET) - View service logs" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment