Files
gravl/scripts/build-check.sh
T
clawd 53f4df6e3c feat(07-02): Add CI/CD deployment scripts
- scripts/deploy.sh: Full deploy flow with fresh builds (--no-cache)
- scripts/build-check.sh: Pre-flight staleness check
- Docker labels for build tracking (git commit + timestamp)
- Prevents stale container bug from recurring
2026-03-03 17:20:23 +01:00

42 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
# Compare deployed container versions against local git HEAD
# Warns if containers are stale (built from an older commit)
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_DIR="$(dirname "$SCRIPT_DIR")"
cd "$REPO_DIR"
LOCAL_COMMIT=$(git rev-parse HEAD)
echo "Local HEAD: $(git rev-parse --short HEAD) ($LOCAL_COMMIT)"
echo ""
check() {
local name="$1"
if ! docker inspect "$name" &>/dev/null; then
echo "[$name] Not running"
return
fi
local commit date
commit=$(docker inspect "$name" --format '{{index .Config.Labels "org.opencontainers.image.revision"}}' 2>/dev/null)
date=$(docker inspect "$name" --format '{{index .Config.Labels "org.opencontainers.image.created"}}' 2>/dev/null)
if [ -z "$commit" ] || [ "$commit" = "unknown" ]; then
echo "[$name] WARNING: no build label found — redeploy with scripts/deploy.sh to add tracking"
return
fi
echo "[$name] Built: ${commit:0:7} on ${date:-unknown}"
if [ "$commit" = "$LOCAL_COMMIT" ]; then
echo "[$name] OK: up to date"
else
echo "[$name] STALE: container is behind local code — run scripts/deploy.sh"
fi
}
check "gravl-backend"
check "gravl-frontend"