Files
MOPC-Portal/scripts/update.sh
Matt b5425e705e
All checks were successful
Build and Push Docker Image / build (push) Successful in 10m33s
Apply full refactor updates plus pipeline/email UX confirmations
2026-02-14 15:26:42 +01:00

46 lines
1.4 KiB
Bash

#!/bin/bash
# =============================================================================
# MOPC Platform - Update / Redeploy Script
# =============================================================================
# Usage: ./scripts/update.sh
# Pulls the latest image from the registry and restarts the app.
# PostgreSQL is NOT restarted.
set -e
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
DOCKER_DIR="$PROJECT_DIR/docker"
echo "============================================"
echo " MOPC Platform - Update"
echo "============================================"
echo ""
# 1. Pull and recreate app only (postgres stays running)
echo "==> Pulling latest image and recreating app..."
cd "$DOCKER_DIR"
docker compose up -d --pull always --force-recreate app
# 2. Wait for health check
echo "==> Waiting for application to start..."
MAX_WAIT=120
WAITED=0
while [ $WAITED -lt $MAX_WAIT ]; do
if curl -sf http://localhost:7600/api/health > /dev/null 2>&1; then
echo ""
echo "============================================"
echo " Update complete! App is healthy."
echo "============================================"
exit 0
fi
sleep 2
WAITED=$((WAITED + 2))
printf "."
done
echo ""
echo "WARNING: Application did not become healthy within ${MAX_WAIT}s."
echo "Check logs: cd $DOCKER_DIR && docker compose logs -f app"
exit 1