Some checks failed
Deploy Nexus / deploy (push) Has been cancelled
Co-authored-by: Claude (Opus 4.6) <claude@hermes.local> Co-committed-by: Claude (Opus 4.6) <claude@hermes.local>
35 lines
1.0 KiB
Bash
Executable File
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 …"
|
|
nginx -t && systemctl reload nginx
|
|
|
|
echo "==> Done. $SERVICE is live."
|