From ac41090ed306b71bce411f417c42d227d07ed264 Mon Sep 17 00:00:00 2001 From: Jp Date: Thu, 26 Feb 2026 11:14:39 +0800 Subject: [PATCH] feat(Makefile): add remote server deployment target Add deploy-server target to deploy application to a remote Kubernetes cluster. Includes server configuration variables and uses scp/ssh for file transfer and kubectl commands for applying configuration and deployment. --- Makefile | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index d54854b..daa106b 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,11 @@ IMG := mkm-admin build: podman build -t $(IMG) . +# Server configuration (Change these to your actual server details) +SERVER_USER := user +SERVER_IP := 192.168.100.105 +SERVER_PATH := /var/www/mkm-admin + deploy: build @if [ ! -f .env ]; then cp .env.example .env; fi @echo "Cleaning up existing deployment if any..." @@ -12,10 +17,20 @@ deploy: build @echo "---" >> k8s/merged_deployment.yaml @cat k8s/deployment.yaml >> k8s/merged_deployment.yaml @echo "Deploying via podman kube play..." - podman kube play k8s/merged_deployment.yaml # Remove the pipe to stderr to see full output + podman kube play k8s/merged_deployment.yaml @rm k8s/merged_deployment.yaml +deploy-server: + @echo "Deploying to remote server $(SERVER_IP)..." + @if [ ! -f .env ]; then cp .env.example .env; fi + ssh $(SERVER_USER)@$(SERVER_IP) "mkdir -p $(SERVER_PATH)/k8s" + scp .env $(SERVER_USER)@$(SERVER_IP):$(SERVER_PATH)/.env + scp k8s/deployment.yaml $(SERVER_USER)@$(SERVER_IP):$(SERVER_PATH)/k8s/deployment.yaml + ssh $(SERVER_USER)@$(SERVER_IP) "cd $(SERVER_PATH) && \ + kubectl create configmap mkm-admin-config --from-env-file=.env --dry-run=client -o yaml | kubectl apply -f - && \ + kubectl apply -f k8s/deployment.yaml" + stop: -podman kube down k8s/deployment.yaml >/dev/null 2>&1 -.PHONY: build deploy stop +.PHONY: build deploy deploy-server stop