Complete Flask → FastAPI migration with: - FastAPI app with session auth, Azure AD SSO, rate limiting - SQLite-backed session store (survives restarts) - Bulk AI metadata generation with SSE progress - Admin panel (user management, audit log, AI usage) - Subpath deployment support (ROOT_PATH config) - Docker + deploy.sh for production deployment - Test suite (auth, upload, templates, imports, admin, sessions) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
78 lines
2.1 KiB
Bash
Executable file
78 lines
2.1 KiB
Bash
Executable file
#!/bin/bash
|
|
# Solventum Image Metadata — Idempotent Deployment Script
|
|
# Usage: ./deploy.sh
|
|
#
|
|
# First run:
|
|
# cd /opt/oliver-metadata-tool
|
|
# cp .env.example .env # edit with your secrets
|
|
# chmod +x deploy.sh
|
|
# ./deploy.sh
|
|
#
|
|
# Subsequent updates:
|
|
# cd /opt/oliver-metadata-tool && ./deploy.sh
|
|
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
COMPOSE_PROJECT="solventum-image-metadata"
|
|
|
|
cd "$SCRIPT_DIR"
|
|
|
|
echo "=== Solventum Image Metadata — Deploy ==="
|
|
echo "Directory: $SCRIPT_DIR"
|
|
echo ""
|
|
|
|
# 1. Pull latest code from Bitbucket
|
|
echo ">>> Pulling latest code..."
|
|
git pull
|
|
|
|
# 2. Check .env exists (first-run guard)
|
|
if [ ! -f .env ]; then
|
|
echo ""
|
|
echo "ERROR: .env file not found!"
|
|
echo ""
|
|
echo " cp .env.example .env"
|
|
echo " Then edit .env with your secrets (AZURE_CLIENT_SECRET, SECRET_KEY, etc.)"
|
|
echo ""
|
|
exit 1
|
|
fi
|
|
|
|
# 3. Build Docker image (uses layer cache, picks up code changes via COPY . .)
|
|
echo ">>> Building Docker image..."
|
|
docker compose -p "$COMPOSE_PROJECT" build
|
|
|
|
# 4. Start or restart containers (idempotent — creates if missing, restarts if running)
|
|
echo ">>> Starting containers..."
|
|
docker compose -p "$COMPOSE_PROJECT" up -d
|
|
|
|
# 5. Wait for health check
|
|
# Database auto-initializes on first container startup:
|
|
# - Tables created via CREATE TABLE IF NOT EXISTS
|
|
# - Migrations run in-code (check-before-act pattern)
|
|
# - Superadmin created if SUPERADMIN_EMAIL is set
|
|
echo ">>> Waiting for app to be healthy..."
|
|
HEALTHY=false
|
|
for i in $(seq 1 20); do
|
|
if curl -sf http://127.0.0.1:5001/login > /dev/null 2>&1; then
|
|
echo ">>> App is healthy!"
|
|
HEALTHY=true
|
|
break
|
|
fi
|
|
echo " Waiting... ($i/20)"
|
|
sleep 3
|
|
done
|
|
|
|
if [ "$HEALTHY" = false ]; then
|
|
echo ""
|
|
echo "WARNING: App may not be healthy after 60 seconds."
|
|
echo "Check logs:"
|
|
echo " docker compose -p $COMPOSE_PROJECT logs --tail 50"
|
|
echo ""
|
|
exit 1
|
|
fi
|
|
|
|
echo ""
|
|
echo "=== Deploy complete ==="
|
|
echo "URL: https://ai-sandbox.oliver.solutions/solventum-image-metadata/"
|
|
echo ""
|
|
docker compose -p "$COMPOSE_PROJECT" ps
|