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:
6
Makefile
6
Makefile
@@ -21,11 +21,13 @@ deploy: build
|
|||||||
|
|
||||||
deploy-server:
|
deploy-server:
|
||||||
@echo "Deploying to remote server $(SERVER_IP)..."
|
@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
|
@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
|
@echo "---" >> /tmp/server_deploy.yaml
|
||||||
@cat k8s/deployment.yaml >> /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
|
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"
|
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
|
@rm -f /tmp/server_deploy.yaml
|
||||||
|
|||||||
Reference in New Issue
Block a user