]> Nutra Git (v1) - nutratech/vps-root.git/commitdiff
update make target: deploy
authorShane Jaroch <chown_tee@proton.me>
Sat, 10 Jan 2026 19:30:45 +0000 (14:30 -0500)
committerShane Jaroch <chown_tee@proton.me>
Sat, 10 Jan 2026 19:34:17 +0000 (14:34 -0500)
Makefile
scripts/deploy.sh

index e9f5083eced7ee0c47488bbbcd261a3e5235c07b..a8ef6405340dd0a002b419d0cb14c5c1b02e28f9 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -3,22 +3,53 @@
 
 -include .env
 
+.PHONY: _help
+_help:
+       @printf "\nUsage: make <command>, valid commands:\n\n"
+       @awk 'BEGIN {FS = ":.*?##H "}; \
+                       /##H/ && !/@awk.*?##H/ { \
+                                       target=$$1; doc=$$2; \
+                                       category="General"; \
+                                       if (doc ~ /^@/) { \
+                                                       category=substr(doc, 2, index(doc, " ")-2); \
+                                                       doc=substr(doc, index(doc, " ")+1); \
+                                       } \
+                                       if (length(target) > max) max = length(target); \
+                                       targets[NR] = target; docs[NR] = doc; cats[NR] = category; \
+                       } \
+                       END { \
+                                       last_cat = ""; \
+                                       for (i = 1; i <= NR; i++) { \
+                                                       if (cats[i] != "") { \
+                                                                       if (cats[i] != last_cat) { \
+                                                                                       printf "\n\033[1;36m%s Commands:\033[0m\n", cats[i]; \
+                                                                                       last_cat = cats[i]; \
+                                                                       } \
+                                                                       printf "  \033[1;34m%-*s\033[0m  %s\n", max, targets[i], docs[i]; \
+                                                       } \
+                                       } \
+                                       print ""; \
+                       }' $(MAKEFILE_LIST)
+
+
+
+
 VPS_HOST ?= dev.nutra.tk
 VPS_USER ?= gg
 VPS = $(VPS_USER)@$(VPS_HOST)
 
 .PHONY: stage/nginx
-stage/nginx:
+stage/nginx:   ##H @Deploy Stage files for deployment
        @echo "Staging files on $(VPS_HOST)..."
-       tar --transform 's|.*/||' -czf - etc/nginx/conf.d/*.conf scripts/deploy.sh | \
-               ssh $(VPS) "rm -rf ~/nginx-staging && mkdir -p ~/nginx-staging && tar -xzv -C ~/nginx-staging"
+       tar --transform 's|.*/||' --exclude='secrets.conf' -czf - etc/nginx/conf.d/*.conf scripts/deploy.sh | \
+               ssh $(VPS) "rm -rf ~/.nginx-staging && mkdir -p ~/.nginx-staging && tar -xzv -C ~/.nginx-staging"
 
 .PHONY: diff/nginx
-diff/nginx:
+diff/nginx:    ##H @Deploy See diff, test with nginx -t
        @echo "Checking diff against $(VPS_HOST)..."
-       ssh -t $(VPS) "bash ~/nginx-staging/deploy.sh diff"
+       ssh -t $(VPS) "bash ~/.nginx-staging/deploy.sh diff"
 
 .PHONY: deploy/nginx
-deploy/nginx:
+deploy/nginx:  ##H @Deploy Copy into place and reload nginx
        @echo "Deploying checked-in nginx config to $(VPS_HOST)..."
-       ssh -t $(VPS) "bash ~/nginx-staging/deploy.sh"
+       ssh -t $(VPS) "bash ~/.nginx-staging/deploy.sh"
index c587beea5caf3f96b5f8a0f88fc19acb67ae63a1..9384e990b13401b48c8786e0cebe425d3526086f 100644 (file)
@@ -13,6 +13,11 @@ echo ""
 echo "Running pre-flight validation on staged config..."
 TMP_NGINX_CONF=$(mktemp)
 
+# Create a temporary nginx.conf that points to STAGING_DIR instead of /etc/nginx/conf.d
+# We assume the standard include is "/etc/nginx/conf.d/*.conf"
+# We strictly replace that string with our staging path.
+sed "s|/etc/nginx/conf.d/\*\.conf|$STAGING_DIR/*.conf|g" /etc/nginx/nginx.conf > "$TMP_NGINX_CONF"
+
 if sudo nginx -t -c "$TMP_NGINX_CONF"; then
     echo "✓ Pre-flight validation passed."
     rm "$TMP_NGINX_CONF"