-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
225 lines (189 loc) · 6.99 KB
/
Makefile
File metadata and controls
225 lines (189 loc) · 6.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
.PHONY: help build start stop restart logs clean dev shell rebuild install lint format test type-check generate-client dev-mock-server dev-mock-oidc compose-up compose-up-dev compose-up-mock compose-down compose-logs compose-build
# Variables
IMAGE_NAME := toolhive-cloud-ui
IMAGE_TAG := latest
CONTAINER_NAME := toolhive-cloud-ui
PORT := 3000
RELEASE_NAME := toolhive-cloud-ui
## Show this help message
help:
@echo "ToolHive Cloud UI - Available Commands"
@echo ""
@echo "Development (pnpm):"
@echo " make install - Install dependencies (pnpm install)"
@echo " make dev - Run dev server with OIDC mock and MSW"
@echo " make dev-next - Run only Next.js dev server"
@echo " make dev-mock-server - Run Next.js with MSW (requires real OIDC)"
@echo " make dev-mock-oidc - Run Next.js with OIDC mock (requires real API)"
@echo " make lint - Run linter (Biome)"
@echo " make format - Format code (Biome)"
@echo " make test - Run tests (Vitest)"
@echo " make type-check - TypeScript type checking"
@echo " make generate-client - Generate API client from backend"
@echo ""
@echo "Docker Compose (Full Stack):"
@echo " make compose-up - Start full stack with Okta (set OIDC env vars first)"
@echo " make compose-up-dev - Start full stack without rebuild (uses existing images)"
@echo " make compose-up-mock - Start full stack with mock OIDC"
@echo " make compose-down - Stop all services"
@echo " make compose-logs - View all service logs"
@echo " make compose-build - Rebuild all images"
@echo ""
@echo "Docker (UI Only):"
@echo " make build - Build production Docker image"
@echo " make start - Start Docker container"
@echo " make stop - Stop Docker container"
@echo " make logs - View container logs"
@echo " make clean - Remove container and image"
@echo " make rebuild - Clean and rebuild"
@echo ""
@echo "Kind (Kubernetes):"
@echo " make kind-setup - Create cluster and deploy (first time)"
@echo " make kind-create - Create Kind cluster"
@echo " make kind-deploy - Build and deploy to Kind"
@echo " make kind-port-forward - Port-forward to localhost:8080"
@echo " make kind-logs - View application logs"
@echo " make kind-uninstall - Uninstall from Kind"
@echo " make kind-delete - Delete Kind cluster"
## Build the production docker image
build:
@echo "Building ${IMAGE_NAME}:${IMAGE_TAG} Docker image..."
@docker build -t $(IMAGE_NAME):$(IMAGE_TAG) .
## Start the production docker container
start:
@docker run -d -p $(PORT):$(PORT) --name $(CONTAINER_NAME) $(IMAGE_NAME):$(IMAGE_TAG)
@echo "Container $(CONTAINER_NAME) running at http://localhost:$(PORT)"
## Stop the production docker container
stop:
@docker stop $(CONTAINER_NAME) > /dev/null 2>&1 || true
@docker rm $(CONTAINER_NAME) > /dev/null 2>&1 || true
@echo "Container $(CONTAINER_NAME) stopped"
## Restart the production docker container
restart: stop start
## Show container logs (follow mode)
logs:
docker logs -f $(CONTAINER_NAME)
## Remove container and image
clean: stop
@docker rmi $(IMAGE_NAME):$(IMAGE_TAG) > /dev/null 2>&1 || true
@echo "Cleanup complete"
## Install dependencies
install:
@echo "Installing dependencies with pnpm..."
@pnpm install
## Run development server with OIDC mock and MSW mock server
dev:
@echo "Starting dev server (Next.js + OIDC + MSW)..."
@pnpm dev
## Run only Next.js dev server
dev-next:
@echo "Starting Next.js dev server only..."
@pnpm dev:next
## Run Next.js with MSW mock server (requires real OIDC configured)
dev-mock-server:
@echo "Starting Next.js with MSW mock server (requires OIDC in .env.local)..."
@pnpm dev:mock-server
## Run Next.js with OIDC mock (requires real backend API configured)
dev-mock-oidc:
@echo "Starting Next.js with OIDC mock (requires API_BASE_URL in .env.local)..."
@pnpm dev:mock-oidc
## Run linter
lint:
@echo "Running linter..."
@pnpm lint
## Format code
format:
@echo "Formatting code..."
@pnpm format
## Run tests
test:
@echo "Running tests..."
@pnpm test
## TypeScript type checking
type-check:
@echo "Type checking..."
@pnpm type-check
## Generate API client from backend
generate-client:
@echo "Generating API client..."
@pnpm generate-client
## Open shell in running container
shell:
docker exec -it $(CONTAINER_NAME) /bin/sh
## Clean and rebuild image
rebuild: clean build
@echo "Rebuild complete"
## Create Kind cluster
kind-create:
@echo "Creating Kind cluster..."
@kind create cluster --name toolhive || echo "Cluster already exists"
@kubectl cluster-info --context kind-toolhive
@echo "Kind cluster ready!"
## Delete Kind cluster
kind-delete:
@echo "Deleting Kind cluster..."
@kind delete cluster --name toolhive
@echo "Cluster deleted"
## Build and load image into Kind
kind-build:
@echo "Building Docker image..."
@docker build -t $(IMAGE_NAME):$(IMAGE_TAG) .
@echo "Loading image into Kind cluster..."
@kind load docker-image $(IMAGE_NAME):$(IMAGE_TAG) --name toolhive
@echo "Image loaded successfully"
## Deploy to Kind with Helm
kind-deploy: kind-build
@echo "Deploying to Kind..."
@helm upgrade --install $(RELEASE_NAME) ./helm -f ./helm/values-dev.yaml --wait --timeout=5m
@echo "Deployment complete!"
@echo ""
@echo "To access the application, run:"
@echo " make kind-port-forward"
@echo "Then open: http://localhost:8080"
## Uninstall from Kind
kind-uninstall:
@helm uninstall $(RELEASE_NAME) || true
@echo "Uninstalled from Kind"
## View logs
kind-logs:
@kubectl logs -f deployment/$(RELEASE_NAME)
## Port-forward to localhost
kind-port-forward:
@echo "Forwarding to http://localhost:8080"
@kubectl port-forward svc/$(RELEASE_NAME) 8080:80
## Full setup: create cluster and deploy
kind-setup: kind-create kind-deploy
@echo "Setup complete!"
# ============================================================================
# Docker Compose (Full Stack with Registry Server)
# ============================================================================
## Start full stack with Okta (requires OIDC env vars or .env file)
## Create a .env file with:
## OIDC_ISSUER_URL=https://your-org.okta.com
## OIDC_CLIENT_ID=your-client-id
## OIDC_CLIENT_SECRET=your-client-secret
## OIDC_PROVIDER_ID=okta
## BETTER_AUTH_SECRET=your-secret
compose-up:
@echo "Starting full stack (UI + Registry Server)..."
@echo "Using OIDC config from environment or .env file"
@docker compose up --build
## Start full stack without rebuild (uses existing images)
compose-up-dev:
@echo "Starting full stack (using existing images)..."
@docker compose up -d
## Start full stack with mock OIDC provider
compose-up-mock:
@echo "Starting full stack with mock OIDC..."
@docker compose --profile mock up --build
## Stop all docker compose services
compose-down:
@echo "Stopping all services..."
@docker compose --profile mock down
## View docker compose logs
compose-logs:
@docker compose logs -f
## Rebuild all docker compose images
compose-build:
@echo "Rebuilding all images..."
@docker compose --profile mock build