chore: remove obsolete deploy scripts (ai-sandbox era)
Some checks failed
Deploy Backend / Deploy API to Cloud Run (push) Has been cancelled
Deploy Frontend / Build and Deploy Frontend (push) Has been cancelled
CI / Backend Lint & Test (push) Has been cancelled
CI / Frontend Lint & Test (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
CI / Dependency Check (push) Has been cancelled
Deploy Backend / Deploy Worker to Cloud Run (push) Has been cancelled
Deploy Backend / Run Smoke Tests (push) Has been cancelled
Deploy Backend / Notify Deployment Status (push) Has been cancelled
Deploy Frontend / Notify Deployment Status (push) Has been cancelled
CI / Integration Tests (push) Has been cancelled
CI / Build Backend Docker Image (push) Has been cancelled
CI / Build Frontend (push) Has been cancelled

deploy.sh and full-deploy.sh predate the optical-dev setup and reference
old URLs/compose files. deploy-dev.sh is the single source of truth.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Vadym Samoilenko 2026-04-30 12:10:57 +01:00
parent 5e55d9f27a
commit 90cbf23f0d
2 changed files with 0 additions and 653 deletions

View file

@ -1,289 +0,0 @@
#!/bin/bash
# =============================================================================
# Deployment Script for Accessible Video Platform
# =============================================================================
# This script handles building and deploying the application
# Run from: /opt/video-accessibility/
# Usage: ./scripts/deploy.sh [options]
# =============================================================================
set -e # Exit on any error
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Configuration
PROJECT_DIR="/opt/video-accessibility"
COMPOSE_FILES="-f docker-compose.yml -f docker-compose.prod.yml --env-file .env.production"
# =============================================================================
# Helper Functions
# =============================================================================
print_header() {
echo -e "${BLUE}==============================================================================${NC}"
echo -e "${BLUE}$1${NC}"
echo -e "${BLUE}==============================================================================${NC}"
}
print_success() {
echo -e "${GREEN} $1${NC}"
}
print_error() {
echo -e "${RED} $1${NC}"
}
print_warning() {
echo -e "${YELLOW}<EFBFBD> $1${NC}"
}
print_info() {
echo -e "${BLUE}9 $1${NC}"
}
# =============================================================================
# Pre-flight Checks
# =============================================================================
preflight_checks() {
print_header "Running Pre-flight Checks"
# Check if running from correct directory
if [ ! -f "docker-compose.yml" ]; then
print_error "docker-compose.yml not found. Please run from /opt/video-accessibility/"
exit 1
fi
print_success "Running from correct directory"
# Check if .env.production exists
if [ ! -f ".env.production" ]; then
print_error ".env.production not found. Please create it first."
exit 1
fi
print_success ".env.production found"
# Check if secrets directory exists
if [ ! -d "secrets" ]; then
print_error "secrets/ directory not found. Please create it and add gcp-credentials.json"
exit 1
fi
print_success "secrets/ directory found"
# Check if GCP credentials exist
if [ ! -f "secrets/gcp-credentials.json" ]; then
print_error "secrets/gcp-credentials.json not found"
exit 1
fi
print_success "GCP credentials found"
# Check if Docker is running
if ! docker info > /dev/null 2>&1; then
print_error "Docker is not running"
exit 1
fi
print_success "Docker is running"
# Check if docker compose is available
if ! docker compose version &> /dev/null; then
print_error "docker compose is not installed"
exit 1
fi
print_success "docker compose is available"
echo ""
}
# =============================================================================
# Pull Latest Code
# =============================================================================
pull_code() {
print_header "Pulling Latest Code"
if [ -d ".git" ]; then
print_info "Pulling monorepo..."
git pull origin main
print_success "Code updated"
elif [ -d "backend/.git" ]; then
print_info "Pulling backend repository..."
cd backend && git pull && cd ..
print_success "Backend code updated"
if [ -d "frontend/.git" ]; then
print_info "Pulling frontend repository..."
cd frontend && git pull && cd ..
print_success "Frontend code updated"
else
print_warning "Frontend is not a git repository, skipping pull"
fi
else
print_error "No git repository found. Cannot pull latest code."
exit 1
fi
echo ""
}
# =============================================================================
# Build and Deploy Backend
# =============================================================================
deploy_backend() {
print_header "Building and Deploying Backend Services"
# Load environment variables
export $(cat .env.production | grep -v '^#' | xargs)
# Build images
print_info "Building Docker images (this may take a few minutes)..."
docker compose $COMPOSE_FILES build --no-cache
print_success "Docker images built"
# Stop existing containers
print_info "Stopping existing containers..."
docker compose $COMPOSE_FILES down
print_success "Containers stopped"
# Start services
print_info "Starting services..."
docker compose $COMPOSE_FILES up -d
print_success "Services started"
# Wait for services to be healthy
print_info "Waiting for services to be healthy..."
sleep 10
# Check service health
if docker compose $COMPOSE_FILES ps | grep -q "unhealthy"; then
print_error "Some services are unhealthy!"
docker compose $COMPOSE_FILES ps
exit 1
fi
print_success "All services are healthy"
echo ""
}
# =============================================================================
# Build and Deploy Frontend
# =============================================================================
deploy_frontend() {
print_header "Building and Deploying Frontend"
cd frontend
# Install dependencies (including dev deps needed for build)
print_info "Installing frontend dependencies..."
npm ci
print_success "Dependencies installed"
# Build frontend
print_info "Building frontend..."
npm run build
print_success "Frontend built"
# Deploy to Apache
print_info "Deploying frontend to /var/www/html/video-accessibility/..."
# Create directory if it doesn't exist
sudo mkdir -p /var/www/html/video-accessibility
# Copy built files
sudo rm -rf /var/www/html/video-accessibility/*
sudo cp -r dist/* /var/www/html/video-accessibility/
# Set proper permissions
sudo chown -R www-data:www-data /var/www/html/video-accessibility
sudo chmod -R 755 /var/www/html/video-accessibility
print_success "Frontend deployed to Apache"
cd ..
echo ""
}
# =============================================================================
# Run Database Migrations
# =============================================================================
run_migrations() {
print_header "Running Database Migrations"
print_info "Checking migration status..."
docker compose $COMPOSE_FILES exec -T api python migrate.py status
print_info "Applying pending migrations..."
docker compose $COMPOSE_FILES exec -T api python migrate.py up
print_success "Migrations completed"
echo ""
}
# =============================================================================
# Display Status
# =============================================================================
display_status() {
print_header "Deployment Status"
echo -e "${BLUE}Container Status:${NC}"
docker compose $COMPOSE_FILES ps
echo ""
echo -e "${BLUE}Service URLs:${NC}"
echo "Frontend: https://ai-sandbox.oliver.solutions/video-accessibility"
echo "Backend API: https://ai-sandbox.oliver.solutions/video-accessibility-back"
echo "API Health: https://ai-sandbox.oliver.solutions/video-accessibility-back/health"
echo ""
echo -e "${GREEN}Deployment completed successfully!${NC}"
echo ""
echo "To view logs:"
echo " docker compose $COMPOSE_FILES logs -f [service]"
echo ""
echo "To restart a service:"
echo " docker compose $COMPOSE_FILES restart [service]"
echo ""
}
# =============================================================================
# Main Deployment Flow
# =============================================================================
main() {
print_header "Accessible Video Platform Deployment"
echo ""
# Run checks
preflight_checks
# Pull latest code
if [ "$1" != "--skip-pull" ]; then
pull_code
fi
# Deploy backend
deploy_backend
# Deploy frontend
if [ "$1" != "--skip-frontend" ]; then
deploy_frontend
fi
# Run migrations
if [ "$1" != "--skip-migrations" ]; then
run_migrations
fi
# Display status
display_status
}
# Run main function
main "$@"

View file

@ -1,364 +0,0 @@
#!/bin/bash
# =============================================================================
# Full Deployment Script for Accessible Video Platform
# =============================================================================
# Rebuilds containers and deploys frontend
# Run from: /opt/video-accessibility/
#
# IMPORTANT: Run git pull BEFORE this script (as your user, not sudo):
# cd /opt/video-accessibility
# git pull origin main
# cd backend && git pull origin main && cd ..
# cd frontend && git pull origin main && cd ..
# sudo ./scripts/full-deploy.sh
#
# Options:
# --frontend-only Only build and deploy frontend (skip Docker rebuild)
# =============================================================================
set -e # Exit on any error
# Parse command line arguments
FRONTEND_ONLY=false
if [[ "$1" == "--frontend-only" ]]; then
FRONTEND_ONLY=true
fi
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Configuration
PROJECT_DIR="/opt/video-accessibility"
FRONTEND_DEPLOY_DIR="/var/www/html/video-accessibility"
COMPOSE_FILES="-f docker-compose.yml -f docker-compose.prod.yml --env-file .env.production"
# =============================================================================
# Helper Functions
# =============================================================================
print_header() {
echo -e "${BLUE}==============================================================================${NC}"
echo -e "${BLUE}$1${NC}"
echo -e "${BLUE}==============================================================================${NC}"
}
print_success() {
echo -e "${GREEN} $1${NC}"
}
print_error() {
echo -e "${RED} $1${NC}"
}
print_warning() {
echo -e "${YELLOW}<EFBFBD> $1${NC}"
}
print_info() {
echo -e "${BLUE}9 $1${NC}"
}
# =============================================================================
# Pre-flight Checks
# =============================================================================
preflight_checks() {
print_header "Pre-flight Checks"
# Check if running as root or with sudo
if [ "$EUID" -ne 0 ]; then
print_error "Please run with sudo"
exit 1
fi
print_success "Running with sudo"
# Check if in correct directory
if [ ! -f "docker-compose.yml" ]; then
print_error "docker-compose.yml not found. Please run from $PROJECT_DIR"
exit 1
fi
print_success "Running from correct directory"
# Check if .env.production exists
if [ ! -f ".env.production" ]; then
print_error ".env.production not found. Please create it first."
exit 1
fi
print_success ".env.production found"
# Check if secrets directory exists
if [ ! -d "secrets" ]; then
print_error "secrets/ directory not found"
exit 1
fi
print_success "secrets/ directory found"
# Check if GCP credentials exist
if [ ! -f "secrets/gcp-credentials.json" ]; then
print_error "secrets/gcp-credentials.json not found"
exit 1
fi
print_success "GCP credentials found"
# Check if Docker is running
if ! docker info > /dev/null 2>&1; then
print_error "Docker is not running"
exit 1
fi
print_success "Docker is running"
echo ""
}
# =============================================================================
# Verify Code is Up to Date
# =============================================================================
verify_code_updated() {
print_header "Verifying Code Status"
print_warning "Make sure you ran 'git pull origin main' BEFORE running this script!"
print_info "Git pull should be run as your user (not sudo) to use your SSH key"
# Show last commit info as verification
if [ -d ".git" ]; then
print_info "Current commit (root):"
git log -1 --oneline 2>/dev/null || print_warning "Could not read git log"
fi
if [ -d "backend/.git" ]; then
print_info "Current commit (backend):"
cd backend && git log -1 --oneline 2>/dev/null && cd .. || print_warning "Could not read backend git log"
fi
if [ -d "frontend/.git" ]; then
print_info "Current commit (frontend):"
cd frontend && git log -1 --oneline 2>/dev/null && cd .. || print_warning "Could not read frontend git log"
fi
echo ""
}
# =============================================================================
# Rebuild and Restart Containers
# =============================================================================
rebuild_containers() {
print_header "Rebuilding Docker Containers"
# Load environment variables
print_info "Loading environment variables from .env.production..."
export $(cat .env.production | grep -v '^#' | xargs)
print_info "Building images (this may take several minutes)..."
docker compose $COMPOSE_FILES build --no-cache
print_success "Docker images built"
print_info "Stopping existing containers..."
docker compose $COMPOSE_FILES down
print_success "Containers stopped"
print_info "Starting services..."
docker compose $COMPOSE_FILES up -d
print_success "Services started"
print_info "Waiting for services to be healthy (30 seconds)..."
sleep 30
# Check if containers are running
print_info "Checking container status..."
docker compose $COMPOSE_FILES ps
# Check for unhealthy containers
if docker compose $COMPOSE_FILES ps | grep -q "unhealthy"; then
print_warning "Some services may be unhealthy, check logs"
else
print_success "All services appear healthy"
fi
echo ""
}
# =============================================================================
# Build and Deploy Frontend
# =============================================================================
build_and_deploy_frontend() {
print_header "Building and Deploying Frontend"
cd frontend
# Install dependencies
print_info "Installing frontend dependencies..."
npm ci
print_success "Dependencies installed"
# Build frontend
print_info "Building React application..."
npm run build
print_success "Frontend build completed"
# Check if build succeeded
if [ ! -d "dist" ]; then
print_error "Build failed - dist directory not found"
exit 1
fi
# Display build size
BUILD_SIZE=$(du -sh dist | cut -f1)
print_info "Build size: $BUILD_SIZE"
cd ..
# Deploy to Apache
print_info "Deploying to $FRONTEND_DEPLOY_DIR..."
# Clear and deploy
print_info "Clearing deployment directory..."
rm -rf "$FRONTEND_DEPLOY_DIR"/*
print_success "Directory cleared"
print_info "Copying build artifacts..."
cp -r frontend/dist/* "$FRONTEND_DEPLOY_DIR"/
print_success "Files copied"
# Set ownership and permissions
print_info "Setting ownership to www-data..."
chown -R www-data:www-data "$FRONTEND_DEPLOY_DIR"
print_success "Ownership set"
print_info "Setting permissions..."
find "$FRONTEND_DEPLOY_DIR" -type d -exec chmod 755 {} \;
find "$FRONTEND_DEPLOY_DIR" -type f -exec chmod 644 {} \;
print_success "Permissions set"
# Verify deployment
if [ ! -f "$FRONTEND_DEPLOY_DIR/index.html" ]; then
print_error "Deployment verification failed - index.html not found"
exit 1
fi
print_success "Deployment verified"
echo ""
}
# =============================================================================
# Run Database Migrations
# =============================================================================
run_migrations() {
print_header "Running Database Migrations"
print_info "Checking migration status..."
docker compose $COMPOSE_FILES exec -T api python migrate.py status
print_info "Applying pending migrations..."
docker compose $COMPOSE_FILES exec -T api python migrate.py up
print_success "Migrations completed"
echo ""
}
# =============================================================================
# Display Deployment Summary
# =============================================================================
display_summary() {
print_header "Deployment Summary"
echo -e "${BLUE}Container Status:${NC}"
docker compose $COMPOSE_FILES ps
echo ""
echo -e "${GREEN} Deployment completed successfully!${NC}"
echo ""
echo -e "${BLUE}Service URLs:${NC}"
echo " Frontend: https://ai-sandbox.oliver.solutions/video-accessibility"
echo " Backend API: https://ai-sandbox.oliver.solutions/video-accessibility-back"
echo " API Health: https://ai-sandbox.oliver.solutions/video-accessibility-back/health"
echo ""
echo -e "${BLUE}Useful Commands:${NC}"
echo " View logs: sudo docker compose $COMPOSE_FILES logs -f [service]"
echo " Restart service: sudo docker compose $COMPOSE_FILES restart [service]"
echo " Check status: sudo docker compose $COMPOSE_FILES ps"
echo ""
}
# =============================================================================
# Main Deployment Flow
# =============================================================================
main() {
if [ "$FRONTEND_ONLY" = true ]; then
print_header "Frontend-Only Deployment - Accessible Video Platform"
echo ""
echo "This script will:"
echo " 1. Verify code status"
echo " 2. Build and deploy frontend"
echo ""
echo "Docker containers will NOT be rebuilt (faster deployment)"
echo ""
echo -e "${YELLOW}REMINDER: You should have run 'git pull origin main' first!${NC}"
echo ""
# Confirm before proceeding
read -p "Have you pulled the latest frontend code? Continue? (y/N) " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
print_warning "Deployment cancelled"
exit 0
fi
echo ""
else
print_header "Full Deployment - Accessible Video Platform"
echo ""
echo "This script will:"
echo " 1. Verify code status"
echo " 2. Rebuild all Docker containers"
echo " 3. Restart all services"
echo " 4. Build and deploy frontend"
echo ""
echo -e "${YELLOW}REMINDER: You should have run 'git pull origin main' first!${NC}"
echo -e "${BLUE}TIP: Use --frontend-only flag to skip Docker rebuild${NC}"
echo ""
# Confirm before proceeding
read -p "Have you pulled the latest code? Continue? (y/N) " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
print_warning "Deployment cancelled"
exit 0
fi
echo ""
fi
if [ "$FRONTEND_ONLY" = true ]; then
# Frontend-only deployment
preflight_checks
verify_code_updated
build_and_deploy_frontend
print_header "Frontend Deployment Complete"
echo -e "${GREEN}✓ Frontend deployed successfully!${NC}"
echo ""
echo "Frontend URL: https://ai-sandbox.oliver.solutions/video-accessibility"
echo ""
else
# Full deployment
preflight_checks
verify_code_updated
rebuild_containers
run_migrations
build_and_deploy_frontend
display_summary
fi
print_success "Deployment complete! 🚀"
}
# Run main function
main "$@"