#!/usr/bin/env bash # Deploy latest code from git and rebuild containers. # Usage: ./deploy.sh (rebuilds site, api, workers) # ./deploy.sh site (rebuilds only site) # ./deploy.sh api (rebuilds only api) # ./deploy.sh erpnext (rebuild + migrate ERPNext, re-extract assets) # ./deploy.sh api workers (rebuild a custom set) set -euo pipefail cd /opt/performancewest SERVICES="${@:-site api workers proxy-relay listmonk-hc}" # proxy-relay and listmonk-hc are upstream images (no build context). Build # everything else, but always include them in the `up` set so the healthcare # proxy sidecar and the healthcare-stream Listmonk run. # NB: listmonk-hc needs a one-time DB setup the first time it is deployed: # docker compose exec api-postgres psql -U pw -d postgres -c 'CREATE DATABASE listmonk_hc OWNER pw;' # docker compose run --rm --entrypoint /bin/sh listmonk-hc -c './listmonk --install --idempotent --yes --config /listmonk/config.toml' # then configure its 3 SMTP servers (hc ports 2526/2527/2528). See # docs/healthcare-email-stream-plan.md. BUILD_SERVICES="$(echo "$SERVICES" | tr ' ' '\n' | grep -vE '^(proxy-relay|listmonk-hc)$' | tr '\n' ' ')" echo "=== Pulling latest from git ===" # deploy steps below (sync_nav.py, gen-service-catalog.py) rewrite generated # files under site/public + site/src in place, leaving the tree dirty. That dirty # tree makes `git pull` abort ("local changes would be overwritten"), silently # stranding new commits on an old checkout. Discard those generated changes first # so the pull always fast-forwards. (Only generated paths are reset.) git checkout -- site/public site/src 2>/dev/null || true git pull origin main # Single source of truth for the site header: rewrite every static page's #