ci: build image remotely before deploying to server

Previously the image was built locally and pushed to a registry. Now we build directly on the remote server to simplify the deployment flow and avoid registry dependencies.
This commit is contained in:
Jp
2026-02-26 11:34:48 +08:00
parent 5992b28eb5
commit cea2749252

View File

@@ -21,11 +21,13 @@ deploy: build
deploy-server:
@echo "Deploying to remote server $(SERVER_IP)..."
@# Generate temporary merged YAML for server in /tmp to avoid WSL permissions
@# Build image on the remote server
ssh $(SERVER_USER)@$(SERVER_IP) "cd $(SERVER_PATH) && sudo podman build -t $(IMG) ."
@# Generate temporary merged YAML for server in /tmp
@sudo kubectl create configmap mkm-admin-config --from-env-file=.env --dry-run=client -o yaml > /tmp/server_deploy.yaml
@echo "---" >> /tmp/server_deploy.yaml
@cat k8s/deployment.yaml >> /tmp/server_deploy.yaml
@# Single SCP/SSH call to reduce password prompts
@# Single SCP/SSH call to apply
scp /tmp/server_deploy.yaml $(SERVER_USER)@$(SERVER_IP):/tmp/server_deploy.yaml
ssh $(SERVER_USER)@$(SERVER_IP) "sudo kubectl apply -f /tmp/server_deploy.yaml && rm -f /tmp/server_deploy.yaml"
@rm -f /tmp/server_deploy.yaml