|
| 1 | +.PHONY: help setup-env build-all build-frontend build-backend build-operator build-runner deploy clean dev-frontend dev-backend lint test registry-login push-all |
| 2 | + |
| 3 | +# Default target |
| 4 | +help: ## Show this help message |
| 5 | + @echo 'Usage: make [target]' |
| 6 | + @echo '' |
| 7 | + @echo 'Configuration Variables:' |
| 8 | + @echo ' CONTAINER_ENGINE Container engine to use (default: docker, can be set to podman)' |
| 9 | + @echo ' PLATFORM Target platform (e.g., linux/amd64, linux/arm64)' |
| 10 | + @echo ' BUILD_FLAGS Additional flags to pass to build command' |
| 11 | + @echo ' REGISTRY Container registry for push operations' |
| 12 | + @echo '' |
| 13 | + @echo 'Examples:' |
| 14 | + @echo ' make setup-env # Create .env from template' |
| 15 | + @echo ' make build-all CONTAINER_ENGINE=podman' |
| 16 | + @echo ' make build-all PLATFORM=linux/amd64' |
| 17 | + @echo ' make build-all BUILD_FLAGS="--no-cache --pull"' |
| 18 | + @echo ' make build-all CONTAINER_ENGINE=podman PLATFORM=linux/arm64' |
| 19 | + @echo '' |
| 20 | + @echo 'Targets:' |
| 21 | + @awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf " %-15s %s\n", $$1, $$2}' $(MAKEFILE_LIST) |
| 22 | + |
| 23 | +# Container engine configuration |
| 24 | +CONTAINER_ENGINE ?= docker |
| 25 | +PLATFORM ?= |
| 26 | +BUILD_FLAGS ?= |
| 27 | + |
| 28 | +# Construct platform flag if PLATFORM is set |
| 29 | +ifneq ($(PLATFORM),) |
| 30 | +PLATFORM_FLAG := --platform=$(PLATFORM) |
| 31 | +else |
| 32 | +PLATFORM_FLAG := |
| 33 | +endif |
| 34 | + |
| 35 | +# Docker image tags |
| 36 | +FRONTEND_IMAGE ?= claude-runner-frontend:latest |
| 37 | +BACKEND_IMAGE ?= claude-runner-backend:latest |
| 38 | +OPERATOR_IMAGE ?= research-operator:latest |
| 39 | +RUNNER_IMAGE ?= claude-runner:latest |
| 40 | + |
| 41 | +# Build all images |
| 42 | +build-all: build-frontend build-backend build-operator build-runner ## Build all container images |
| 43 | + |
| 44 | +# Build individual components |
| 45 | +build-frontend: ## Build the frontend container image |
| 46 | + @echo "Building frontend image with $(CONTAINER_ENGINE)..." |
| 47 | + cd frontend && $(CONTAINER_ENGINE) build $(PLATFORM_FLAG) $(BUILD_FLAGS) -t $(FRONTEND_IMAGE) . |
| 48 | + |
| 49 | +build-backend: ## Build the backend API container image |
| 50 | + @echo "Building backend image with $(CONTAINER_ENGINE)..." |
| 51 | + cd backend && $(CONTAINER_ENGINE) build $(PLATFORM_FLAG) $(BUILD_FLAGS) -t $(BACKEND_IMAGE) . |
| 52 | + |
| 53 | +build-operator: ## Build the operator container image |
| 54 | + @echo "Building operator image with $(CONTAINER_ENGINE)..." |
| 55 | + cd operator && $(CONTAINER_ENGINE) build $(PLATFORM_FLAG) $(BUILD_FLAGS) -t $(OPERATOR_IMAGE) . |
| 56 | + |
| 57 | +build-runner: ## Build the Claude runner container image |
| 58 | + @echo "Building Claude runner image with $(CONTAINER_ENGINE)..." |
| 59 | + cd claude-runner && $(CONTAINER_ENGINE) build $(PLATFORM_FLAG) $(BUILD_FLAGS) -t $(RUNNER_IMAGE) . |
| 60 | + |
| 61 | +# Development targets |
| 62 | +dev-frontend: ## Start frontend in development mode |
| 63 | + cd frontend && npm install && npm run dev |
| 64 | + |
| 65 | +dev-backend: ## Start backend in development mode |
| 66 | + cd backend && go run main.go |
| 67 | + |
| 68 | +dev-operator: ## Start operator in development mode |
| 69 | + cd operator && go run main.go |
| 70 | + |
| 71 | +# Environment setup |
| 72 | +setup-env: ## Create .env file from template |
| 73 | + @if [ ! -f .env ]; then \ |
| 74 | + echo "Creating .env file from template..."; \ |
| 75 | + cp manifests/env.example .env; \ |
| 76 | + echo "✓ Created .env file. Please edit it with your actual values:"; \ |
| 77 | + echo " - Set ANTHROPIC_API_KEY to your actual API key"; \ |
| 78 | + echo " - Adjust other settings as needed"; \ |
| 79 | + else \ |
| 80 | + echo ".env file already exists"; \ |
| 81 | + fi |
| 82 | + |
| 83 | +# Kubernetes deployment |
| 84 | +deploy: ## Deploy all components to Kubernetes |
| 85 | + @echo "Deploying to Kubernetes..." |
| 86 | + cd manifests && ./deploy.sh |
| 87 | + |
| 88 | +deploy-crd: ## Deploy only the Custom Resource Definition |
| 89 | + kubectl apply -f manifests/crd.yaml |
| 90 | + |
| 91 | +deploy-rbac: ## Deploy only RBAC configuration |
| 92 | + kubectl apply -f manifests/rbac.yaml |
| 93 | + |
| 94 | +deploy-secrets: ## Deploy secrets and config |
| 95 | + kubectl apply -f manifests/secrets.yaml |
| 96 | + |
| 97 | +deploy-backend: ## Deploy only the backend service |
| 98 | + kubectl apply -f manifests/backend-deployment.yaml |
| 99 | + |
| 100 | +deploy-operator: ## Deploy only the operator |
| 101 | + kubectl apply -f manifests/operator-deployment.yaml |
| 102 | + |
| 103 | +deploy-frontend: ## Deploy only the frontend |
| 104 | + kubectl apply -f manifests/frontend-deployment.yaml |
| 105 | + |
| 106 | +# Cleanup |
| 107 | +clean: ## Clean up all Kubernetes resources |
| 108 | + @echo "Cleaning up Kubernetes resources..." |
| 109 | + cd manifests && ./deploy.sh clean |
| 110 | + |
| 111 | +# Status and monitoring |
| 112 | +status: ## Show deployment status |
| 113 | + @echo "Deployment Status:" |
| 114 | + @echo "==================" |
| 115 | + kubectl get pods -l 'app in (backend-api,research-operator,frontend)' -n claude-research |
| 116 | + @echo "" |
| 117 | + kubectl get services -l 'app in (backend-api,frontend)' -n claude-research |
| 118 | + @echo "" |
| 119 | + kubectl get researchsessions -n claude-research |
| 120 | + |
| 121 | +logs-backend: ## View backend logs |
| 122 | + kubectl logs -l app=backend-api -f -n claude-research |
| 123 | + |
| 124 | +logs-operator: ## View operator logs |
| 125 | + kubectl logs -l app=research-operator -f -n claude-research |
| 126 | + |
| 127 | +logs-frontend: ## View frontend logs |
| 128 | + kubectl logs -l app=frontend -f -n claude-research |
| 129 | + |
| 130 | +# Port forwarding for local access |
| 131 | +port-forward-frontend: ## Port forward frontend service to localhost:3000 |
| 132 | + kubectl port-forward svc/frontend-service 3000:3000 -n claude-research |
| 133 | + |
| 134 | +port-forward-backend: ## Port forward backend service to localhost:8080 |
| 135 | + kubectl port-forward svc/backend-service 8080:8080 -n claude-research |
| 136 | + |
| 137 | +# Development setup with Kind |
| 138 | +kind-create: ## Create a local Kubernetes cluster with Kind |
| 139 | + kind create cluster --name claude-research |
| 140 | + |
| 141 | +kind-load: build-all ## Load all images into Kind cluster |
| 142 | + kind load $(CONTAINER_ENGINE)-image $(FRONTEND_IMAGE) --name claude-research |
| 143 | + kind load $(CONTAINER_ENGINE)-image $(BACKEND_IMAGE) --name claude-research |
| 144 | + kind load $(CONTAINER_ENGINE)-image $(OPERATOR_IMAGE) --name claude-research |
| 145 | + kind load $(CONTAINER_ENGINE)-image $(RUNNER_IMAGE) --name claude-research |
| 146 | + |
| 147 | +kind-deploy: kind-load deploy ## Deploy to Kind cluster |
| 148 | + |
| 149 | +kind-clean: ## Delete the Kind cluster |
| 150 | + kind delete cluster --name claude-research |
| 151 | + |
| 152 | +# Linting and testing |
| 153 | +lint-frontend: ## Lint frontend code |
| 154 | + cd frontend && npm run lint |
| 155 | + |
| 156 | +lint-backend: ## Lint backend code |
| 157 | + cd backend && go fmt ./... && go vet ./... |
| 158 | + |
| 159 | +lint-operator: ## Lint operator code |
| 160 | + cd operator && go fmt ./... && go vet ./... |
| 161 | + |
| 162 | +lint: lint-frontend lint-backend lint-operator ## Lint all code |
| 163 | + |
| 164 | +# Testing |
| 165 | +test-frontend: ## Run frontend tests |
| 166 | + cd frontend && npm test |
| 167 | + |
| 168 | +test-backend: ## Run backend tests |
| 169 | + cd backend && go test ./... |
| 170 | + |
| 171 | +test-operator: ## Run operator tests |
| 172 | + cd operator && go test ./... |
| 173 | + |
| 174 | +test: test-frontend test-backend test-operator ## Run all tests |
| 175 | + |
| 176 | +# Docker registry operations (customize REGISTRY as needed) |
| 177 | +REGISTRY ?= your-registry.com |
| 178 | + |
| 179 | +push-all: build-all ## Push all images to registry |
| 180 | + $(CONTAINER_ENGINE) tag $(FRONTEND_IMAGE) $(REGISTRY)/$(FRONTEND_IMAGE) |
| 181 | + $(CONTAINER_ENGINE) tag $(BACKEND_IMAGE) $(REGISTRY)/$(BACKEND_IMAGE) |
| 182 | + $(CONTAINER_ENGINE) tag $(OPERATOR_IMAGE) $(REGISTRY)/$(OPERATOR_IMAGE) |
| 183 | + $(CONTAINER_ENGINE) tag $(RUNNER_IMAGE) $(REGISTRY)/$(RUNNER_IMAGE) |
| 184 | + $(CONTAINER_ENGINE) push $(REGISTRY)/$(FRONTEND_IMAGE) |
| 185 | + $(CONTAINER_ENGINE) push $(REGISTRY)/$(BACKEND_IMAGE) |
| 186 | + $(CONTAINER_ENGINE) push $(REGISTRY)/$(OPERATOR_IMAGE) |
| 187 | + $(CONTAINER_ENGINE) push $(REGISTRY)/$(RUNNER_IMAGE) |
| 188 | + |
| 189 | +# Utility targets |
| 190 | +install-deps: ## Install development dependencies |
| 191 | + @echo "Installing frontend dependencies..." |
| 192 | + cd frontend && npm install |
| 193 | + @echo "Installing Go dependencies..." |
| 194 | + cd backend && go mod tidy |
| 195 | + cd operator && go mod tidy |
| 196 | + |
| 197 | +create-namespace: ## Create the claude-research namespace if it doesn't exist |
| 198 | + kubectl apply -f manifests/namespace.yaml |
| 199 | + |
| 200 | +# Example research session |
| 201 | +create-example: ## Create an example research session |
| 202 | + kubectl apply -f - <<EOF |
| 203 | + apiVersion: research.example.com/v1 |
| 204 | + kind: ResearchSession |
| 205 | + metadata: |
| 206 | + name: example-research |
| 207 | + namespace: claude-research |
| 208 | + spec: |
| 209 | + prompt: "Analyze this website and provide insights about its design and user experience" |
| 210 | + websiteURL: "https://example.com" |
| 211 | + llmSettings: |
| 212 | + model: "claude-3-5-sonnet-20241022" |
| 213 | + temperature: 0.7 |
| 214 | + maxTokens: 4000 |
| 215 | + timeout: 300 |
| 216 | + EOF |
| 217 | + |
| 218 | +# Full development setup |
| 219 | +dev-setup: install-deps build-all kind-create kind-deploy ## Complete development setup |
0 commit comments