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>
165 lines
3.6 KiB
Bash
Executable file
165 lines
3.6 KiB
Bash
Executable file
#!/bin/bash
|
||
# Oliver Metadata Tool - Docker Management Script
|
||
|
||
set -e
|
||
|
||
# Colors for output
|
||
RED='\033[0;31m'
|
||
GREEN='\033[0;32m'
|
||
YELLOW='\033[1;33m'
|
||
BLUE='\033[0;34m'
|
||
NC='\033[0m' # No Color
|
||
|
||
# Functions
|
||
print_header() {
|
||
echo -e "${BLUE}============================================${NC}"
|
||
echo -e "${BLUE} Oliver Metadata Tool - Docker Manager${NC}"
|
||
echo -e "${BLUE}============================================${NC}"
|
||
}
|
||
|
||
print_success() {
|
||
echo -e "${GREEN}✓ $1${NC}"
|
||
}
|
||
|
||
print_error() {
|
||
echo -e "${RED}✗ $1${NC}"
|
||
}
|
||
|
||
print_info() {
|
||
echo -e "${YELLOW}ℹ $1${NC}"
|
||
}
|
||
|
||
# Check if Docker is installed
|
||
check_docker() {
|
||
if ! command -v docker &> /dev/null; then
|
||
print_error "Docker is not installed. Please install Docker first."
|
||
exit 1
|
||
fi
|
||
|
||
if ! command -v docker-compose &> /dev/null && ! docker compose version &> /dev/null; then
|
||
print_error "Docker Compose is not installed. Please install Docker Compose first."
|
||
exit 1
|
||
fi
|
||
}
|
||
|
||
# Build Docker image
|
||
build() {
|
||
print_header
|
||
print_info "Building Docker image..."
|
||
docker-compose build
|
||
print_success "Docker image built successfully"
|
||
}
|
||
|
||
# Start containers
|
||
start() {
|
||
print_header
|
||
print_info "Starting Oliver Metadata Tool..."
|
||
docker-compose up -d
|
||
print_success "Application started successfully"
|
||
print_info "Access the application at: http://localhost:5001"
|
||
print_info "Default credentials: tester / oliveradmin"
|
||
}
|
||
|
||
# Stop containers
|
||
stop() {
|
||
print_header
|
||
print_info "Stopping Oliver Metadata Tool..."
|
||
docker-compose down
|
||
print_success "Application stopped successfully"
|
||
}
|
||
|
||
# View logs
|
||
logs() {
|
||
print_header
|
||
print_info "Showing application logs (Ctrl+C to exit)..."
|
||
docker-compose logs -f
|
||
}
|
||
|
||
# Restart containers
|
||
restart() {
|
||
print_header
|
||
print_info "Restarting Oliver Metadata Tool..."
|
||
docker-compose restart
|
||
print_success "Application restarted successfully"
|
||
}
|
||
|
||
# Show status
|
||
status() {
|
||
print_header
|
||
docker-compose ps
|
||
}
|
||
|
||
# Clean up (remove containers and volumes)
|
||
clean() {
|
||
print_header
|
||
print_error "WARNING: This will remove all containers, volumes, and data!"
|
||
read -p "Are you sure? (yes/no): " confirm
|
||
if [ "$confirm" == "yes" ]; then
|
||
print_info "Cleaning up..."
|
||
docker-compose down -v
|
||
print_success "Cleanup completed"
|
||
else
|
||
print_info "Cleanup cancelled"
|
||
fi
|
||
}
|
||
|
||
# Show help
|
||
show_help() {
|
||
print_header
|
||
echo ""
|
||
echo "Usage: ./docker-run.sh [command]"
|
||
echo ""
|
||
echo "Commands:"
|
||
echo " build - Build Docker image"
|
||
echo " start - Start the application"
|
||
echo " stop - Stop the application"
|
||
echo " restart - Restart the application"
|
||
echo " logs - View application logs"
|
||
echo " status - Show container status"
|
||
echo " clean - Remove containers and volumes (WARNING: deletes data)"
|
||
echo " help - Show this help message"
|
||
echo ""
|
||
echo "Examples:"
|
||
echo " ./docker-run.sh build # Build image"
|
||
echo " ./docker-run.sh start # Start application"
|
||
echo " ./docker-run.sh logs # View logs"
|
||
echo ""
|
||
}
|
||
|
||
# Main script
|
||
check_docker
|
||
|
||
case "$1" in
|
||
build)
|
||
build
|
||
;;
|
||
start)
|
||
start
|
||
;;
|
||
stop)
|
||
stop
|
||
;;
|
||
restart)
|
||
restart
|
||
;;
|
||
logs)
|
||
logs
|
||
;;
|
||
status)
|
||
status
|
||
;;
|
||
clean)
|
||
clean
|
||
;;
|
||
help|--help|-h)
|
||
show_help
|
||
;;
|
||
"")
|
||
show_help
|
||
;;
|
||
*)
|
||
print_error "Unknown command: $1"
|
||
show_help
|
||
exit 1
|
||
;;
|
||
esac
|