Files
the-nexus/deploy.sh

35 lines
1.0 KiB
Bash
Raw Normal View History

#!/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 …"
nginx -t && systemctl reload nginx
echo "==> Done. $SERVICE is live."