-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
update Makefile, make development simpler #171
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,3 +32,6 @@ cmd/ops | |
#local db files | ||
*.db | ||
*.db-journal | ||
|
||
# local api pid | ||
.api.pid |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,178 @@ | ||
# Basic variables | ||
GOOS ?= $(shell go env GOOS) | ||
GOARCH ?= $(shell go env GOARCH) | ||
VERSION ?= $(shell hack/version.sh) | ||
# Images management | ||
REGISTRY ?= "docker.io/karmada" | ||
REGISTRY_USER_NAME ?= "" | ||
REGISTRY_PASSWORD ?= "" | ||
REGISTRY_SERVER_ADDRESS ?= "" | ||
|
||
# Default target when just running 'make' | ||
.DEFAULT_GOAL := all | ||
|
||
# Build targets | ||
TARGETS := karmada-dashboard-api \ | ||
karmada-dashboard-web \ | ||
|
||
|
||
# Build binary. | ||
# | ||
# Args: | ||
# GOOS: OS to build. | ||
# GOARCH: Arch to build. | ||
# | ||
# Example: | ||
# make | ||
# make all | ||
# make karmada-dashboard-api GOOS=linux | ||
karmada-dashboard-web | ||
|
||
# Docker image related variables | ||
REGISTRY ?= docker.io/karmada | ||
REGISTRY_USER_NAME ?= | ||
REGISTRY_PASSWORD ?= | ||
REGISTRY_SERVER_ADDRESS ?= | ||
IMAGE_TARGET := $(addprefix image-, $(TARGETS)) | ||
|
||
# Development server variables | ||
KARMADA_CTX ?= karmada-apiserver | ||
HOST_CTX ?= karmada-host | ||
API_PORT ?= 8000 | ||
API_HOST ?= http://localhost:8000 | ||
SKIP_TLS_VERIFY ?= false | ||
KUBECONFIG ?= $(HOME)/.kube/karmada.config | ||
|
||
################### | ||
# Build Targets # | ||
################### | ||
|
||
# Build all binaries (alias for build) | ||
.PHONY: all | ||
all: build | ||
|
||
# Build all binaries | ||
.PHONY: build | ||
build: $(TARGETS) | ||
|
||
# Build specific binary | ||
.PHONY: $(TARGETS) | ||
$(TARGETS): | ||
BUILD_PLATFORMS=$(GOOS)/$(GOARCH) hack/build.sh $@ | ||
|
||
.PHONY: all | ||
all: $(TARGETS) | ||
|
||
# Build image. | ||
# | ||
# Args: | ||
# GOARCH: Arch to build. | ||
# OUTPUT_TYPE: Destination to save image(docker/registry). | ||
# | ||
# Example: | ||
# make images | ||
# make image-karmada-dashboard-api | ||
# make image-karmada-dashboard-api GOARCH=arm64 | ||
IMAGE_TARGET=$(addprefix image-, $(TARGETS)) | ||
################### | ||
# Docker Images # | ||
################### | ||
|
||
# Build all images | ||
.PHONY: images | ||
images: $(IMAGE_TARGET) | ||
|
||
# Build specific image | ||
.PHONY: $(IMAGE_TARGET) | ||
$(IMAGE_TARGET): | ||
set -e;\ | ||
target=$$(echo $(subst image-,,$@));\ | ||
make $$target GOOS=linux;\ | ||
VERSION=$(VERSION) REGISTRY=$(REGISTRY) BUILD_PLATFORMS=linux/$(GOARCH) hack/docker.sh $$target | ||
|
||
################### | ||
# UI Building # | ||
################### | ||
|
||
.PHONY: bundle-ui-dashboard | ||
bundle-ui-dashboard: | ||
cd ui && pnpm run dashboard:build | ||
bin-karmada-dashboard-web: | ||
BUILD_PLATFORMS=$(GOOS)/$(GOARCH) hack/build.sh karmada-dashboard-web | ||
image-karmada-dashboard-web: | ||
BUILD_PLATFORMS=linux/$(GOARCH) hack/build.sh karmada-dashboard-web | ||
cp -R ui/apps/dashboard/dist _output/bin/linux/$(GOARCH)/dist | ||
DOCKER_FILE="build-web.Dockerfile" VERSION=$(VERSION) REGISTRY=$(REGISTRY) BUILD_PLATFORMS=linux/$(GOARCH) hack/docker.sh karmada-dashboard-web | ||
|
||
################### | ||
# Dependencies # | ||
################### | ||
|
||
# Install Go dependencies | ||
.PHONY: install-deps | ||
install-deps: | ||
go mod tidy | ||
go mod verify | ||
|
||
# Install UI dependencies | ||
.PHONY: install-ui-deps | ||
install-ui-deps: | ||
cd ui && pnpm install | ||
|
||
# Install all dependencies | ||
.PHONY: install | ||
install: install-deps install-ui-deps | ||
|
||
################### | ||
# Development # | ||
################### | ||
|
||
# Run both API and Web server | ||
.PHONY: run | ||
run: | ||
ifndef KUBECONFIG | ||
$(error KUBECONFIG is required. Please specify the path to karmada kubeconfig) | ||
endif | ||
@echo "Starting API server..." | ||
@_output/bin/$(GOOS)/$(GOARCH)/karmada-dashboard-api \ | ||
--karmada-kubeconfig=$(KUBECONFIG) \ | ||
samzong marked this conversation as resolved.
Show resolved
Hide resolved
|
||
--karmada-context=$(KARMADA_CTX) \ | ||
--kubeconfig=$(KUBECONFIG) \ | ||
--context=$(HOST_CTX) \ | ||
--insecure-port=$(API_PORT) \ | ||
$(if $(filter true,$(SKIP_TLS_VERIFY)),--skip-karmada-apiserver-tls-verify) & echo $$! > .api.pid | ||
@echo "Starting Web server..." | ||
@cd ui && VITE_API_HOST=$(API_HOST) pnpm run dashboard:dev || (kill `cat .api.pid` && rm .api.pid) | ||
@if [ -f .api.pid ]; then kill `cat .api.pid` && rm .api.pid; fi | ||
|
||
# Run API server only | ||
.PHONY: run-api | ||
run-api: build | ||
ifndef KUBECONFIG | ||
$(error KUBECONFIG is required. Please specify the path to karmada kubeconfig) | ||
endif | ||
_output/bin/$(GOOS)/$(GOARCH)/karmada-dashboard-api \ | ||
--karmada-kubeconfig=$(KUBECONFIG) \ | ||
--karmada-context=$(KARMADA_CTX) \ | ||
--kubeconfig=$(KUBECONFIG) \ | ||
--context=$(HOST_CTX) \ | ||
--insecure-port=$(API_PORT) \ | ||
$(if $(filter true,$(SKIP_TLS_VERIFY)),--skip-karmada-apiserver-tls-verify) | ||
|
||
# Run Web server only | ||
.PHONY: run-web | ||
run-web: install-ui-deps build | ||
cd ui && VITE_API_HOST=$(API_HOST) pnpm run dashboard:dev | ||
|
||
# Generate JWT token for dashboard login | ||
.PHONY: gen-token | ||
gen-token: | ||
ifndef KUBECONFIG | ||
$(error KUBECONFIG is required. Please specify the path to karmada kubeconfig) | ||
endif | ||
@echo "Switching to karmada-apiserver context..." | ||
@kubectl config use-context $(KARMADA_CTX) | ||
@echo "Creating service account..." | ||
@kubectl apply -f artifacts/dashboard/karmada-dashboard-sa.yaml | ||
@echo "Getting JWT token..." | ||
@kubectl -n karmada-system get secret/karmada-dashboard-secret -o go-template="{{.data.token | base64decode}}" | ||
@echo | ||
|
||
################### | ||
# Help # | ||
################### | ||
|
||
# Show help | ||
.PHONY: help | ||
help: | ||
samzong marked this conversation as resolved.
Show resolved
Hide resolved
|
||
@echo "Karmada Dashboard Makefile" | ||
@echo "" | ||
@echo "Usage:" | ||
@echo " make - Build all binaries (same as 'make all')" | ||
@echo " make all - Build all binaries" | ||
@echo " make install - Install all dependencies" | ||
@echo " make run - Run both API and Web servers" | ||
@echo " make images - Build all Docker images" | ||
@echo "" | ||
@echo "Development Commands:" | ||
@echo " make run-api - Run API server only" | ||
@echo " make run-web - Run Web server only" | ||
@echo " make install-deps - Install Go dependencies" | ||
@echo " make install-ui-deps - Install UI dependencies" | ||
@echo " make gen-token - Generate JWT token for dashboard login" | ||
@echo "" | ||
@echo "Build Commands:" | ||
@echo " make build - Build all binaries" | ||
@echo " make images - Build all Docker images" | ||
@echo "" | ||
@echo "Variables:" | ||
@echo " KUBECONFIG - Path to karmada kubeconfig file (default: $(HOME)/.kube/karmada.config)" | ||
@echo " KARMADA_CTX - Karmada API server context (default: karmada-apiserver)" | ||
@echo " HOST_CTX - Host cluster context (default: karmada-host)" | ||
@echo " API_PORT - API server port (default: 8000)" | ||
@echo " API_HOST - API server host (default: http://localhost:8000)" | ||
@echo " GOOS - Target OS for build" | ||
@echo " GOARCH - Target architecture for build" | ||
@echo " SKIP_TLS_VERIFY - Skip TLS verification for Karmada API server (default: false)" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change breaks the CI workflow:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll send a PR to fix it.