From 55d2f61d09c08b4ef3ace67843f7689b9fd0c7e9 Mon Sep 17 00:00:00 2001 From: Jp Date: Thu, 26 Feb 2026 11:23:30 +0800 Subject: [PATCH] ci: streamline server deployment by reducing SSH prompts Generate a temporary merged YAML file locally before copying to the server. This reduces the number of SSH/SCP commands from multiple to two, minimizing password prompts and connection overhead. --- Makefile | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 2d44ce7..bc090e1 100644 --- a/Makefile +++ b/Makefile @@ -21,12 +21,14 @@ deploy: build deploy-server: @echo "Deploying to remote server $(SERVER_IP)..." - 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" + @# Generate temporary merged YAML for server + @kubectl create configmap mkm-admin-config --from-env-file=.env --dry-run=client -o yaml > k8s/server_deploy.yaml + @echo "---" >> k8s/server_deploy.yaml + @cat k8s/deployment.yaml >> k8s/server_deploy.yaml + @# Single SCP/SSH call to reduce password prompts + scp k8s/server_deploy.yaml $(SERVER_USER)@$(SERVER_IP):/tmp/server_deploy.yaml + ssh $(SERVER_USER)@$(SERVER_IP) "kubectl apply -f /tmp/server_deploy.yaml && rm /tmp/server_deploy.yaml" + @rm k8s/server_deploy.yaml stop: -podman kube down k8s/deployment.yaml >/dev/null 2>&1