Add the --cleanup flag to the install-php-extensions command to remove downloaded archives after installation, reducing the final image size. Use the --no-cache flag for the remote podman build in the deployment script to ensure a clean build from the latest source on the server.
39 lines
1.5 KiB
Makefile
39 lines
1.5 KiB
Makefile
IMG := mkm-admin
|
|
|
|
build:
|
|
podman build -t $(IMG) .
|
|
|
|
# Server configuration (Change these to your actual server details)
|
|
SERVER_USER := ubuntu
|
|
SERVER_IP := 192.168.100.200
|
|
SERVER_PATH := /var/www/MKM
|
|
|
|
deploy: build
|
|
@echo "Cleaning up existing deployment if any..."
|
|
-podman kube down k8s/deployment.yaml >/dev/null 2>&1
|
|
@echo "Generating merged deployment with ConfigMap..."
|
|
@sudo kubectl create configmap mkm-admin-config --from-env-file=.env --dry-run=client -o yaml > /tmp/merged_deployment.yaml
|
|
@echo "---" >> /tmp/merged_deployment.yaml
|
|
@cat k8s/deployment.yaml >> /tmp/merged_deployment.yaml
|
|
@echo "Deploying via podman kube play..."
|
|
podman kube play /tmp/merged_deployment.yaml
|
|
@rm /tmp/merged_deployment.yaml
|
|
|
|
deploy-server:
|
|
@echo "Deploying to remote server $(SERVER_IP)..."
|
|
@# Build image on the remote server
|
|
ssh $(SERVER_USER)@$(SERVER_IP) "cd $(SERVER_PATH) && sudo podman build --no-cache -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 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
|
|
|
|
stop:
|
|
-podman kube down k8s/deployment.yaml >/dev/null 2>&1
|
|
|
|
.PHONY: build deploy deploy-server stop
|