#!/usr/bin/env bash # deploy.sh — manual deploy (pull + rebuild + health check) # Run this on the server when you don't want to wait for a webhook trigger. set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" REPO_DIR="$(dirname "$SCRIPT_DIR")" cd "$REPO_DIR" echo "=== Pulling latest code ===" git pull origin master echo "=== Running tests ===" npm ci --silent npm test echo "=== Rebuilding & restarting ===" docker compose up -d --build --remove-orphans echo "=== Waiting for health checks ===" sleep 3 docker compose ps echo "=== Smoke test ===" curl -sf http://localhost:80/health > /dev/null && echo "OK — /health passed" || echo "WARN — /health failed" echo "" echo "Done. App is live."