summaryrefslogtreecommitdiffstats
path: root/internal/templates
diff options
context:
space:
mode:
authorbndw <ben@bdw.to>2026-02-10 21:29:20 -0800
committerbndw <ben@bdw.to>2026-02-10 21:29:20 -0800
commitc49a067ac84ac5c1691ecf4db6a9bf791246899f (patch)
treeefbb94c0d5a79411e91089922151f1ad424e6645 /internal/templates
parent47d4b3b6e4d68660e6e1e05fe2e1c0839f86e40e (diff)
Remove --module flag, add --public, make hooks smarter
Drop git-module type — the post-receive hook now checks for a Dockerfile before building, so repos without one simply skip deploy on push. This covers Go modules and libraries that only need vanity imports. Add --public flag to ship init for per-repo HTTPS clone visibility. Show visibility column in ship list.
Diffstat (limited to 'internal/templates')
-rw-r--r--internal/templates/templates.go27
1 files changed, 20 insertions, 7 deletions
diff --git a/internal/templates/templates.go b/internal/templates/templates.go
index 8615117..8f25f8f 100644
--- a/internal/templates/templates.go
+++ b/internal/templates/templates.go
@@ -99,23 +99,37 @@ while read oldrev newrev refname; do
99 [ "$branch" = "main" ] || { echo "Pushed to $branch, skipping deploy."; exit 0; } 99 [ "$branch" = "main" ] || { echo "Pushed to $branch, skipping deploy."; exit 0; }
100done 100done
101 101
102# Ensure checkout directory exists
103sudo /bin/mkdir -p "$SRC"
104sudo /bin/chown -R git:git "/var/lib/${NAME}"
105
102echo "==> Checking out code..." 106echo "==> Checking out code..."
103git --work-tree="$SRC" --git-dir="$REPO" checkout -f main 107git --work-tree="$SRC" --git-dir="$REPO" checkout -f main
104 108
105cd "$SRC" 109cd "$SRC"
106 110
107# Install deployment config from repo 111# If no Dockerfile, nothing to deploy
108if [ -f .ship/service ]; then 112if [ ! -f Dockerfile ]; then
113 echo "No Dockerfile found, skipping deploy."
114 exit 0
115fi
116
117# Install deployment config from repo (using full paths for sudoers)
118if [ -f "$SRC/.ship/service" ]; then
109 echo "==> Installing systemd unit..." 119 echo "==> Installing systemd unit..."
110 sudo cp .ship/service /etc/systemd/system/${NAME}.service 120 sudo /bin/cp "$SRC/.ship/service" "/etc/systemd/system/${NAME}.service"
111 sudo systemctl daemon-reload 121 sudo systemctl daemon-reload
112fi 122fi
113if [ -f .ship/Caddyfile ]; then 123if [ -f "$SRC/.ship/Caddyfile" ]; then
114 echo "==> Installing Caddy config..." 124 echo "==> Installing Caddy config..."
115 sudo cp .ship/Caddyfile /etc/caddy/sites-enabled/${NAME}.caddy 125 sudo /bin/cp "$SRC/.ship/Caddyfile" "/etc/caddy/sites-enabled/${NAME}.caddy"
116 sudo systemctl reload caddy 126 sudo systemctl reload caddy
117fi 127fi
118 128
129# Ensure data directory exists
130sudo /bin/mkdir -p "/var/lib/${NAME}/data"
131sudo /bin/chown -R git:git "/var/lib/${NAME}/data"
132
119echo "==> Building Docker image..." 133echo "==> Building Docker image..."
120docker build -t ${NAME}:latest . 134docker build -t ${NAME}:latest .
121 135
@@ -142,7 +156,7 @@ git --work-tree="$WEBROOT" --git-dir="$REPO" checkout -f main
142 156
143if [ -f "$WEBROOT/.ship/Caddyfile" ]; then 157if [ -f "$WEBROOT/.ship/Caddyfile" ]; then
144 echo "==> Installing Caddy config..." 158 echo "==> Installing Caddy config..."
145 sudo cp "$WEBROOT/.ship/Caddyfile" /etc/caddy/sites-enabled/${NAME}.caddy 159 sudo /bin/cp "$WEBROOT/.ship/Caddyfile" "/etc/caddy/sites-enabled/${NAME}.caddy"
146 sudo systemctl reload caddy 160 sudo systemctl reload caddy
147fi 161fi
148 162
@@ -164,7 +178,6 @@ var codeCaddyTemplate = `{{.BaseDomain}} {
164 transport fastcgi { 178 transport fastcgi {
165 env SCRIPT_FILENAME /usr/lib/git-core/git-http-backend 179 env SCRIPT_FILENAME /usr/lib/git-core/git-http-backend
166 env GIT_PROJECT_ROOT /srv/git 180 env GIT_PROJECT_ROOT /srv/git
167 env GIT_HTTP_EXPORT_ALL 1
168 env REQUEST_METHOD {method} 181 env REQUEST_METHOD {method}
169 env QUERY_STRING {query} 182 env QUERY_STRING {query}
170 env PATH_INFO {path} 183 env PATH_INFO {path}