Files
forwarder/deploy/deploy-pull.sh
T
1sonhador f6b276511a fix(connection): fail-fast IMAP/SMTP tests; add Gitea webhook autodeploy
Connection tests use 5s timeouts and run IMAP/SMTP in parallel so the UI
gets a clear error instead of nginx 504. Add deploy-hook service (:9090) and
deploy-pull.sh for push-to-main deploys on CT 243.
2026-07-01 01:09:53 +01:00

46 lines
1.2 KiB
Bash

#!/usr/bin/env bash
# BizDocs Forwarder — pull from Gitea + docker compose rebuild (CT 243 / /opt/forwarder).
# Invoked by deploy-hook webhook or manually after SSH setup.
set -euo pipefail
REPO_DIR="${FORWARDER_REPO_DIR:-/opt/forwarder}"
DEPLOY_BRANCH="${DEPLOY_BRANCH:-main}"
COMPOSE="docker compose"
log() { echo "[$(date '+%Y-%m-%d %H:%M:%S')] [forwarder-deploy] $*"; }
if [ ! -d "$REPO_DIR/.git" ]; then
log "FATAL: git repo missing at $REPO_DIR"
exit 1
fi
cd "$REPO_DIR"
log "Fetching origin/$DEPLOY_BRANCH"
git fetch origin "$DEPLOY_BRANCH"
git reset --hard "origin/$DEPLOY_BRANCH"
log "HEAD $(git rev-parse --short HEAD) — $(git log -1 --format=%s)"
if [ ! -f .env ] && [ -f /etc/forwarder/forwarder.env ]; then
log "Linking .env from /etc/forwarder/forwarder.env"
ln -sf /etc/forwarder/forwarder.env .env
fi
if [ ! -f .env ]; then
log "FATAL: .env missing (copy .env.example or /etc/forwarder/forwarder.env)"
exit 1
fi
log "Building containers"
$COMPOSE build
log "Running migrations"
$COMPOSE run --rm migrate
log "Starting stack"
$COMPOSE up -d
log "Health check"
curl -sf --max-time 10 http://127.0.0.1:8000/api/health >/dev/null
log "Deploy OK"