feat: greenfield deployment — no Go required

- install.sh detects if Go is installed
- If Go available: builds from source (current behavior)
- If Go missing: downloads pre-built binary from latest release
- Detects amd64/arm64 architecture automatically
- Same logic applies to -update mode
- Removed hard dependency on ollama.service in systemd unit
This commit is contained in:
Claus Lohmar 2026-05-30 15:49:05 +00:00
parent 59788ba0c8
commit f9a7df1580

View file

@ -69,7 +69,16 @@ if [ "${1:-}" = "-update" ]; then
fi
info "Rebuilding binary..."
CGO_ENABLED=0 go build -ldflags="-s -w" -o receiptnext .
if command -v go &>/dev/null; then
CGO_ENABLED=0 go build -ldflags="-s -w" -o receiptnext .
else
warn "Go not found — downloading pre-built binary..."
TAG=$(curl -fsSL https://git.lohmar.co.uk/api/v1/repos/cclohmar/ReceiptNext/releases/latest \
| python3 -c "import json,sys; print(json.load(sys.stdin).get('tag_name','v1.0.0'))" 2>/dev/null || echo "v1.0.0")
ARCH="$(uname -m)"; [ "$ARCH" = "x86_64" ] && ARCH="amd64"; [ "$ARCH" = "aarch64" ] && ARCH="arm64"
sudo_if curl -fsSL -o receiptnext "https://git.lohmar.co.uk/cclohmar/ReceiptNext/releases/download/${TAG}/receiptnext-linux-${ARCH}"
sudo_if chmod +x receiptnext
fi
info "Restarting service..."
systemctl restart "$SERVICE_NAME"
@ -103,10 +112,26 @@ else
cd "$INSTALL_DIR"
fi
# ── 2. Build binary ──────────────────────────────────────────────
info "Building binary (pure Go, no CGO)..."
CGO_ENABLED=0 go build -ldflags="-s -w" -o receiptnext .
info "Binary built: $INSTALL_DIR/receiptnext"
# ── 2. Build or download binary ──────────────────────────────────
ARCH="$(uname -m)"
case "$ARCH" in
x86_64) ARCH="amd64" ;;
aarch64) ARCH="arm64" ;;
*) err "Unsupported architecture: $ARCH"; exit 1 ;;
esac
if command -v go &>/dev/null; then
info "Building binary from source (pure Go, no CGO)..."
CGO_ENABLED=0 go build -ldflags="-s -w" -o receiptnext .
else
info "Go not found — downloading pre-built binary..."
TAG=$(curl -fsSL https://git.lohmar.co.uk/api/v1/repos/cclohmar/ReceiptNext/releases/latest \
| python3 -c "import json,sys; print(json.load(sys.stdin).get('tag_name','v1.0.0'))" 2>/dev/null || echo "v1.0.0")
URL="https://git.lohmar.co.uk/cclohmar/ReceiptNext/releases/download/${TAG}/receiptnext-linux-${ARCH}"
sudo_if curl -fsSL -o receiptnext "$URL"
sudo_if chmod +x receiptnext
fi
info "Binary ready: $INSTALL_DIR/receiptnext"
# ── 3. Create runtime directories ────────────────────────────────
sudo_if mkdir -p storage
@ -291,8 +316,7 @@ sudo_if tee "/etc/systemd/system/${SERVICE_NAME}.service" > /dev/null << SERVEOF
[Unit]
Description=ReceiptNext — AI-Powered Expense Tracker
Documentation=https://git.lohmar.co.uk/cclohmar/ReceiptNext
After=network.target ollama.service
Wants=ollama.service
After=network.target
[Service]
Type=simple