Files
the-nexus/deploy.sh
Alexander Whitestone 237f2c09a4 fix: add sudo to nginx reload in deploy.sh
Refs #211

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-24 00:35:40 -04:00

35 lines
1.0 KiB
Bash
Executable File

#!/usr/bin/env bash
# deploy.sh — pull latest main and restart the Nexus
#
# Usage (on the VPS):
# ./deploy.sh — deploy nexus-main (port 4200)
# ./deploy.sh staging — deploy nexus-staging (port 4201)
#
# Expected layout on VPS:
# /opt/the-nexus/ ← git clone of this repo (git remote = origin, branch = main)
# nginx site config ← /etc/nginx/sites-enabled/the-nexus
set -euo pipefail
SERVICE="${1:-nexus-main}"
case "$SERVICE" in
staging) SERVICE="nexus-staging" ;;
main) SERVICE="nexus-main" ;;
esac
REPO_DIR="$(cd "$(dirname "$0")" && pwd)"
echo "==> Pulling latest main …"
git -C "$REPO_DIR" fetch origin
git -C "$REPO_DIR" checkout main
git -C "$REPO_DIR" reset --hard origin/main
echo "==> Building and restarting $SERVICE"
docker compose -f "$REPO_DIR/docker-compose.yml" build "$SERVICE"
docker compose -f "$REPO_DIR/docker-compose.yml" up -d --force-recreate "$SERVICE"
echo "==> Reloading nginx …"
sudo nginx -t && sudo systemctl reload nginx
echo "==> Done. $SERVICE is live."