Skip to content

Commit

Permalink
chore: update makefile
Browse files Browse the repository at this point in the history
Signed-off-by: pehlicd <65170388+pehlicd@users.noreply.github.com>
  • Loading branch information
pehlicd committed Oct 12, 2024
1 parent c48a6c8 commit 667c35e
Showing 1 changed file with 67 additions and 16 deletions.
83 changes: 67 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,38 +1,89 @@
NO_COLOR=\033[0m
OK_COLOR=\033[32;01m
ERROR_COLOR=\033[31;01m
WARN_COLOR=\033[33;01m
# ---------------------------------------------------------------------------- #
# ______ ______ ___ _____ _ _ _____ ______ ___ ______ ______ #
# | ___ \| ___ \ / _ \ / __ \ | | | ||_ _||___ / / _ \ | ___ \| _ \ #
# | |_/ /| |_/ // /_\ \| / \/ | | | | | | / / / /_\ \| |_/ /| | | | #
# | / | ___ \| _ || | | |/\| | | | / / | _ || / | | | | #
# | |\ \ | |_/ /| | | || \__/\ \ /\ / _| |_ ./ /___| | | || |\ \ | |/ / #
# \_| \_|\____/ \_| |_/ \____/ \/ \/ \___/ \_____/\_| |_/\_| \_||___/ #
# #
# ---------------------------------------------------------------------------- #

serve: build-ui-completely
# Color Definitions
NO_COLOR = \033[0m
OK_COLOR = \033[32;01m
ERROR_COLOR = \033[31;01m
WARN_COLOR = \033[33;01m

# Directories
APP_NAME = rbac-wizard
BIN_DIR = ./bin
GO_BUILD = $(BIN_DIR)/$(APP_NAME)

# Main Targets
.PHONY: run serve run-ui build-ui build-ui-and-embed build-backend fmt create-cluster delete-cluster deploy-ingress-nginx clean

## Run the application in serve mode
run:
@echo "$(OK_COLOR)==> Running the application...$(NO_COLOR)"
go run . serve

## Serve the application (build UI and backend first)
serve: build-ui-and-embed build-backend
@echo "$(OK_COLOR)==> Starting the application...$(NO_COLOR)"
go run . serve

## Run UI in development mode
run-ui:
@echo "$(OK_COLOR)==> Running UI in development mode...$(NO_COLOR)"
cd ui && npm run dev

## Build the UI
build-ui:
@echo "$(OK_COLOR)==> Building UI...$(NO_COLOR)"
cd ui && npm run build

build-ui-completely: build-ui
## Build UI, embed it into Go application, and clean up artifacts
build-ui-and-embed: build-ui
@echo "$(OK_COLOR)==> Embedding UI files into Go application...$(NO_COLOR)"
statik -src=./ui/dist/ -dest=./internal/ -f
@echo "$(OK_COLOR)==> Cleaning up UI build artifacts...$(NO_COLOR)"
rm -rf ./ui/dist

## Build the Go backend and place the binary in bin directory
build-backend:
@echo "$(OK_COLOR)==> Building Go backend...$(NO_COLOR)"
mkdir -p $(BIN_DIR)
go build -o $(GO_BUILD)

## Format Go code and tidy modules
fmt:
@echo "$(OK_COLOR)==> Formatting Go code and tidying modules...$(NO_COLOR)"
go fmt ./...
go mod tidy

create-cluster:
@echo "$(OK_COLOR)==> Creating the k8s cluster$(NO_COLOR)"
@kind create cluster --config dev/kind.yaml
# Kubernetes Cluster Management
## Create a Kubernetes cluster using Kind
create-k8s-cluster:
@echo "$(OK_COLOR)==> Creating Kubernetes cluster...$(NO_COLOR)"
kind create cluster --config dev/kind.yaml

delete-cluster:
@echo "$(OK_COLOR)==> Deleting the k8s cluster$(NO_COLOR)"
@kind delete cluster -n 'rbac-wizard-dev'
## Delete the Kubernetes cluster
delete-k8s-cluster:
@echo "$(OK_COLOR)==> Deleting Kubernetes cluster...$(NO_COLOR)"
kind delete cluster -n 'rbac-wizard-dev'

## Deploy NGINX Ingress controller to the cluster
deploy-ingress-nginx:
@echo "$(OK_COLOR)==> Deploying the ingress-nginx$(NO_COLOR)"
@kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/deploy/static/provider/kind/deploy.yaml
@kubectl wait --namespace ingress-nginx \
@echo "$(OK_COLOR)==> Deploying ingress-nginx...$(NO_COLOR)"
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/deploy/static/provider/kind/deploy.yaml
@echo "$(OK_COLOR)==> Waiting for ingress-nginx to be ready...$(NO_COLOR)"
kubectl wait --namespace ingress-nginx \
--for=condition=ready pod \
--selector=app.kubernetes.io/component=controller \
--timeout=180s


# Cleanup
## Remove built binaries and cleanup
clean:
@echo "$(OK_COLOR)==> Cleaning up build artifacts...$(NO_COLOR)"
rm -rf $(BIN_DIR)

0 comments on commit 667c35e

Please sign in to comment.