From c49a067ac84ac5c1691ecf4db6a9bf791246899f Mon Sep 17 00:00:00 2001 From: bndw Date: Tue, 10 Feb 2026 21:29:20 -0800 Subject: Remove --module flag, add --public, make hooks smarter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- internal/templates/templates.go | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'internal') 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 [ "$branch" = "main" ] || { echo "Pushed to $branch, skipping deploy."; exit 0; } done +# Ensure checkout directory exists +sudo /bin/mkdir -p "$SRC" +sudo /bin/chown -R git:git "/var/lib/${NAME}" + echo "==> Checking out code..." git --work-tree="$SRC" --git-dir="$REPO" checkout -f main cd "$SRC" -# Install deployment config from repo -if [ -f .ship/service ]; then +# If no Dockerfile, nothing to deploy +if [ ! -f Dockerfile ]; then + echo "No Dockerfile found, skipping deploy." + exit 0 +fi + +# Install deployment config from repo (using full paths for sudoers) +if [ -f "$SRC/.ship/service" ]; then echo "==> Installing systemd unit..." - sudo cp .ship/service /etc/systemd/system/${NAME}.service + sudo /bin/cp "$SRC/.ship/service" "/etc/systemd/system/${NAME}.service" sudo systemctl daemon-reload fi -if [ -f .ship/Caddyfile ]; then +if [ -f "$SRC/.ship/Caddyfile" ]; then echo "==> Installing Caddy config..." - sudo cp .ship/Caddyfile /etc/caddy/sites-enabled/${NAME}.caddy + sudo /bin/cp "$SRC/.ship/Caddyfile" "/etc/caddy/sites-enabled/${NAME}.caddy" sudo systemctl reload caddy fi +# Ensure data directory exists +sudo /bin/mkdir -p "/var/lib/${NAME}/data" +sudo /bin/chown -R git:git "/var/lib/${NAME}/data" + echo "==> Building Docker image..." docker build -t ${NAME}:latest . @@ -142,7 +156,7 @@ git --work-tree="$WEBROOT" --git-dir="$REPO" checkout -f main if [ -f "$WEBROOT/.ship/Caddyfile" ]; then echo "==> Installing Caddy config..." - sudo cp "$WEBROOT/.ship/Caddyfile" /etc/caddy/sites-enabled/${NAME}.caddy + sudo /bin/cp "$WEBROOT/.ship/Caddyfile" "/etc/caddy/sites-enabled/${NAME}.caddy" sudo systemctl reload caddy fi @@ -164,7 +178,6 @@ var codeCaddyTemplate = `{{.BaseDomain}} { transport fastcgi { env SCRIPT_FILENAME /usr/lib/git-core/git-http-backend env GIT_PROJECT_ROOT /srv/git - env GIT_HTTP_EXPORT_ALL 1 env REQUEST_METHOD {method} env QUERY_STRING {query} env PATH_INFO {path} -- cgit v1.2.3