Pre-launch — Gluecron is in final validation. Public signups and git hosting for non-owner users open after launch review.
CodeIssuesDiscussionsWikiPull RequestsProjectsCommitsActionsReleasesContributorsPulse● GatesSecuritySettingsDeploymentsPipelineInsightsAgents✨ Explain✨ Ask AI✨ Workspace✨ Spec✨ Tests▓ Debt Map✨ NL Search🏛 Archaeology
Blame · Line-by-line history

auto-update.sh

Each line is annotated with the commit that last touched it. Click any SHA to jump to that commit and see the surrounding change.

auto-update.shBlame66 lines · 2 contributors
f635e2fClaude1#!/usr/bin/env bash
2#
3# Fast auto-deploy for the standalone box. Installed as a ~60s systemd timer by
4# scripts/standalone-deploy.sh. Polls the deploy branch; when new commits land,
5# it pulls, rebuilds, and runs migrations. Push -> live in ~1-2 min, hands-off.
6#
7# Exits immediately (cheap) when there is nothing new, so a tight interval is fine.
8set -euo pipefail
9
10REPO_DIR="/opt/gluecron"
9de2807Claude11BRANCH="main"
f635e2fClaude12COMPOSE="docker compose -f docker-compose.standalone.yml"
13
14cd "$REPO_DIR"
15git fetch origin "$BRANCH" --quiet
16
17local_sha=$(git rev-parse HEAD)
18remote_sha=$(git rev-parse "origin/$BRANCH")
19[ "$local_sha" = "$remote_sha" ] && exit 0
20
21echo "$(date -Is) deploying $local_sha -> $remote_sha"
22git reset --hard "origin/$BRANCH" # untracked .env / backups are preserved
23
30e70f3ccanty labs24# NOTE: `|| true` is deliberate. On this Coolify co-tenant box the compose
25# also defines a `caddy` service that tries to bind host :80/:443, which
26# Coolify's proxy already owns — so `up` reports a non-zero exit for caddy
27# even though the app (gluecron) started fine. Under `set -e` that would abort
28# the deploy BEFORE the coolify reattach + health gate below. We tolerate the
29# partial failure here and instead gate on the app's OWN health further down.
30$COMPOSE up -d --build || echo "$(date -Is) compose up returned non-zero (likely the co-tenant caddy port conflict) — continuing to app health gate"
f635e2fClaude31sleep 5
5bac517ccanty labs32
33# Co-tenant ingress reattach (Coolify boxes only).
34# `docker compose up --build` recreates the gluecron container, which DROPS
35# any network attachment not declared in docker-compose.standalone.yml. On
36# this box the public ingress is Coolify's Traefik ("coolify-proxy"), which
37# reaches the app over the external "coolify" network via the file route
38# /traefik/dynamic/gluecron.yaml in the coolify-proxy container. Without this
39# reattach, every deploy 502s the site until someone reconnects by hand.
30e70f3ccanty labs40# Idempotent: a no-op if already attached; skipped entirely on a dedicated VPS
41# that has no "coolify" network.
5bac517ccanty labs42if docker network inspect coolify >/dev/null 2>&1; then
43 docker network connect coolify gluecron-gluecron-1 2>/dev/null \
44 && echo "$(date -Is) reattached gluecron to coolify network" \
45 || echo "$(date -Is) coolify network already attached (ok)"
46fi
47
f635e2fClaude48$COMPOSE exec -T gluecron bun run db:migrate || true
49docker image prune -f >/dev/null 2>&1 || true
50
30e70f3ccanty labs51# App health gate — the real success signal (not caddy). Poll the container's
52# own /healthz; if the app itself never comes up, exit non-zero so the systemd
53# unit records a failed deploy instead of a silent green.
54healthy=0
55for _ in $(seq 1 20); do
56 if docker exec gluecron-gluecron-1 wget -qO- --timeout=4 http://localhost:3000/healthz >/dev/null 2>&1; then
57 healthy=1; break
58 fi
59 sleep 3
60done
61if [ "$healthy" != "1" ]; then
62 echo "$(date -Is) DEPLOY FAILED: app /healthz never came up for $remote_sha" >&2
63 exit 1
64fi
65
66echo "$(date -Is) deploy complete: $remote_sha (app healthy)"