Refactor deployment documentation for ScriptShare, consolidating deployment guides into a single comprehensive document while removing outdated Docker deployment files and scripts. Enhance clarity on deployment options across various platforms and streamline the application structure overview.
Some checks failed
Build and Test / test (push) Has been cancelled
Build and Test / docker-build (push) Has been cancelled

This commit is contained in:
2025-08-20 00:43:09 +01:00
parent 68a02d1e5f
commit 58d8886480
17 changed files with 588 additions and 1893 deletions

View File

@ -1,53 +0,0 @@
#!/bin/bash
# ScriptShare Database Backup Script
set -e
# Load environment variables
if [ -f ".env" ]; then
source .env
fi
# Default values
DB_CONTAINER=${DB_CONTAINER:-scriptshare-db}
BACKUP_DIR=${BACKUP_DIR:-./backups}
RETENTION_DAYS=${BACKUP_RETENTION_DAYS:-30}
# Create backup directory
mkdir -p "$BACKUP_DIR"
# Generate backup filename with timestamp
TIMESTAMP=$(date +"%Y%m%d_%H%M%S")
BACKUP_FILE="$BACKUP_DIR/scriptshare_backup_$TIMESTAMP.sql"
echo "🗄️ Starting database backup..."
echo "Backup file: $BACKUP_FILE"
# Create database backup
docker exec "$DB_CONTAINER" mysqldump \
--single-transaction \
--routines \
--triggers \
--all-databases \
-u root \
-p"${DB_ROOT_PASSWORD}" > "$BACKUP_FILE"
# Compress the backup
gzip "$BACKUP_FILE"
BACKUP_FILE="$BACKUP_FILE.gz"
echo "✅ Database backup completed: $BACKUP_FILE"
# Calculate backup size
BACKUP_SIZE=$(du -h "$BACKUP_FILE" | cut -f1)
echo "📦 Backup size: $BACKUP_SIZE"
# Clean up old backups
echo "🧹 Cleaning up old backups (older than $RETENTION_DAYS days)..."
find "$BACKUP_DIR" -name "scriptshare_backup_*.sql.gz" -mtime +$RETENTION_DAYS -delete
# List remaining backups
echo "📋 Current backups:"
ls -lh "$BACKUP_DIR"/scriptshare_backup_*.sql.gz 2>/dev/null || echo "No backups found"
echo "✅ Backup process completed successfully!"

View File

@ -1,92 +0,0 @@
#!/bin/bash
# ScriptShare Production Deployment Script
set -e
echo "🚀 Starting ScriptShare deployment..."
# Check if Docker and Docker Compose are installed
if ! command -v docker &> /dev/null; then
echo "❌ Docker is not installed. Please install Docker first."
exit 1
fi
if ! command -v docker-compose &> /dev/null && ! docker compose version &> /dev/null; then
echo "❌ Docker Compose is not installed. Please install Docker Compose first."
exit 1
fi
# Check if environment file exists
if [ ! -f "env.production" ]; then
echo "❌ Environment file 'env.production' not found."
echo "Please copy 'env.production' and configure your settings."
exit 1
fi
# Create necessary directories
echo "📁 Creating required directories..."
mkdir -p logs
mkdir -p certs
mkdir -p backups
# Copy environment file
cp env.production .env
# Pull latest images
echo "📥 Pulling Docker images..."
docker-compose -f docker-compose.prod.yml pull
# Build custom images
echo "🔨 Building application images..."
docker-compose -f docker-compose.prod.yml build --no-cache
# Stop existing containers if running
echo "🛑 Stopping existing containers..."
docker-compose -f docker-compose.prod.yml down
# Start the application
echo "🚀 Starting ScriptShare application..."
docker-compose -f docker-compose.prod.yml up -d
# Wait for services to be healthy
echo "⏳ Waiting for services to start..."
sleep 30
# Check service health
echo "🏥 Checking service health..."
services=("scriptshare-db" "scriptshare-api" "scriptshare-frontend" "scriptshare-proxy")
for service in "${services[@]}"; do
if docker-compose -f docker-compose.prod.yml ps | grep -q "$service.*Up"; then
echo "$service is running"
else
echo "$service failed to start"
echo "Checking logs for $service:"
docker-compose -f docker-compose.prod.yml logs "$service"
exit 1
fi
done
# Run database migrations if needed
echo "🗃️ Running database migrations..."
docker-compose -f docker-compose.prod.yml exec -T scriptshare-api npm run db:migrate:prod || echo "⚠️ Database migrations not available or failed"
# Display deployment information
echo ""
echo "🎉 ScriptShare deployment completed successfully!"
echo ""
echo "📊 Service URLs:"
echo " Frontend: http://localhost:$(grep PROXY_PORT .env | cut -d'=' -f2 | tr -d '"')"
echo " API: http://localhost:$(grep API_PORT .env | cut -d'=' -f2 | tr -d '"')/api/health"
echo " Database: localhost:$(grep DB_PORT .env | cut -d'=' -f2 | tr -d '"')"
echo ""
echo "🔧 Management commands:"
echo " View logs: docker-compose -f docker-compose.prod.yml logs -f"
echo " Stop: docker-compose -f docker-compose.prod.yml down"
echo " Restart: docker-compose -f docker-compose.prod.yml restart"
echo ""
echo "📝 Next steps:"
echo " 1. Configure your domain DNS to point to this server"
echo " 2. Set up SSL certificates in ./certs/"
echo " 3. Update env.production with your domain settings"
echo " 4. Run: docker-compose -f docker-compose.prod.yml restart scriptshare-proxy"

View File

@ -1,47 +0,0 @@
-- ScriptShare Database Initialization Script
-- This script sets up the initial database structure and default data
USE scriptshare;
-- Create tables if they don't exist (will be handled by Drizzle migrations)
-- This file can be used for any initial data setup
-- Insert default admin user (optional)
-- Note: Password should be properly hashed in production
INSERT IGNORE INTO users (id, email, username, displayName, isAdmin, isModerator, createdAt, updatedAt)
VALUES (
'admin-default-id',
'admin@scriptshare.local',
'admin',
'Administrator',
true,
true,
NOW(),
NOW()
);
-- Insert sample categories
INSERT IGNORE INTO script_categories (name, description) VALUES
('System Administration', 'Scripts for system administration tasks'),
('Development', 'Development and build automation scripts'),
('Backup & Recovery', 'Backup and recovery automation'),
('Monitoring', 'System and application monitoring scripts'),
('Security', 'Security and audit scripts'),
('Database', 'Database management and maintenance'),
('Network', 'Network configuration and management'),
('DevOps', 'DevOps and CI/CD automation');
-- Create indexes for performance
CREATE INDEX IF NOT EXISTS idx_scripts_author ON scripts(authorId);
CREATE INDEX IF NOT EXISTS idx_scripts_created ON scripts(createdAt);
CREATE INDEX IF NOT EXISTS idx_scripts_approved ON scripts(isApproved);
CREATE INDEX IF NOT EXISTS idx_ratings_script ON ratings(scriptId);
CREATE INDEX IF NOT EXISTS idx_analytics_script ON script_analytics(scriptId);
CREATE INDEX IF NOT EXISTS idx_analytics_created ON script_analytics(createdAt);
-- Set up database optimization
SET GLOBAL innodb_buffer_pool_size = 268435456; -- 256MB
SET GLOBAL max_connections = 200;
-- Print initialization complete message
SELECT 'ScriptShare database initialization completed!' as message;

View File

@ -1,142 +0,0 @@
# ScriptShare Management Script for Windows PowerShell
param(
[Parameter(Mandatory=$true, Position=0)]
[string]$Command,
[Parameter(Position=1)]
[string]$Service
)
$ComposeFile = "docker-compose.prod.yml"
function Show-Help {
Write-Host "ScriptShare Management Script" -ForegroundColor Green
Write-Host ""
Write-Host "Usage: .\scripts\manage.ps1 [COMMAND] [SERVICE]" -ForegroundColor Yellow
Write-Host ""
Write-Host "Commands:" -ForegroundColor Cyan
Write-Host " start Start all services"
Write-Host " stop Stop all services"
Write-Host " restart Restart all services"
Write-Host " logs Show logs for all services"
Write-Host " logs [svc] Show logs for specific service"
Write-Host " status Show status of all services"
Write-Host " backup Create database backup"
Write-Host " update Update application (pull, build, restart)"
Write-Host " clean Clean up unused Docker resources"
Write-Host " shell [svc] Open shell in service container"
Write-Host " db Connect to database"
Write-Host " help Show this help message"
Write-Host ""
Write-Host "Services: scriptshare-db, scriptshare-api, scriptshare-frontend, scriptshare-proxy, scriptshare-redis" -ForegroundColor Gray
}
switch ($Command.ToLower()) {
"start" {
Write-Host "🚀 Starting ScriptShare services..." -ForegroundColor Green
docker-compose -f $ComposeFile up -d
Write-Host "✅ Services started" -ForegroundColor Green
}
"stop" {
Write-Host "🛑 Stopping ScriptShare services..." -ForegroundColor Yellow
docker-compose -f $ComposeFile down
Write-Host "✅ Services stopped" -ForegroundColor Green
}
"restart" {
Write-Host "🔄 Restarting ScriptShare services..." -ForegroundColor Yellow
docker-compose -f $ComposeFile restart
Write-Host "✅ Services restarted" -ForegroundColor Green
}
"logs" {
if ($Service) {
Write-Host "📋 Showing logs for $Service..." -ForegroundColor Cyan
docker-compose -f $ComposeFile logs -f $Service
} else {
Write-Host "📋 Showing logs for all services..." -ForegroundColor Cyan
docker-compose -f $ComposeFile logs -f
}
}
"status" {
Write-Host "📊 Service Status:" -ForegroundColor Cyan
docker-compose -f $ComposeFile ps
Write-Host ""
Write-Host "🏥 Health Status:" -ForegroundColor Cyan
$services = @("scriptshare-db", "scriptshare-api", "scriptshare-frontend", "scriptshare-proxy")
foreach ($svc in $services) {
try {
$health = docker inspect --format='{{.State.Health.Status}}' $svc 2>$null
if (-not $health) { $health = "not found" }
Write-Host " $svc`: $health" -ForegroundColor Gray
} catch {
Write-Host " $svc`: not found" -ForegroundColor Red
}
}
}
"backup" {
Write-Host "🗄️ Creating database backup..." -ForegroundColor Cyan
if (Test-Path ".\scripts\backup.sh") {
bash .\scripts\backup.sh
} else {
Write-Host "❌ Backup script not found. Please run manually:" -ForegroundColor Red
Write-Host "docker exec scriptshare-db mysqladmin ping" -ForegroundColor Gray
}
}
"update" {
Write-Host "🔄 Updating ScriptShare application..." -ForegroundColor Cyan
docker-compose -f $ComposeFile pull
docker-compose -f $ComposeFile build --no-cache
docker-compose -f $ComposeFile up -d
Write-Host "✅ Application updated" -ForegroundColor Green
}
"clean" {
Write-Host "🧹 Cleaning up Docker resources..." -ForegroundColor Yellow
docker system prune -f
docker volume prune -f
Write-Host "✅ Cleanup completed" -ForegroundColor Green
}
"shell" {
if (-not $Service) {
Write-Host "❌ Please specify service name" -ForegroundColor Red
Write-Host "Available services: scriptshare-db, scriptshare-api, scriptshare-frontend, scriptshare-proxy" -ForegroundColor Gray
exit 1
}
Write-Host "💻 Opening shell in $Service..." -ForegroundColor Cyan
docker-compose -f $ComposeFile exec $Service /bin/sh
}
"db" {
Write-Host "🗃️ Connecting to database..." -ForegroundColor Cyan
$envFile = ".env"
$dbUser = "scriptshare_user"
$dbPassword = "ScriptShare_App_2024_Secure!"
$dbName = "scriptshare"
if (Test-Path $envFile) {
$env = Get-Content $envFile | ConvertFrom-StringData
if ($env.DB_USER) { $dbUser = $env.DB_USER }
if ($env.DB_PASSWORD) { $dbPassword = $env.DB_PASSWORD }
if ($env.DB_NAME) { $dbName = $env.DB_NAME }
}
docker-compose -f $ComposeFile exec scriptshare-db mysql -u $dbUser -p$dbPassword $dbName
}
"help" {
Show-Help
}
default {
Write-Host "❌ Unknown command: $Command" -ForegroundColor Red
Write-Host ""
Show-Help
exit 1
}
}

View File

@ -1,130 +0,0 @@
#!/bin/bash
# ScriptShare Management Script
set -e
COMPOSE_FILE="docker-compose.prod.yml"
show_help() {
echo "ScriptShare Management Script"
echo ""
echo "Usage: $0 [COMMAND]"
echo ""
echo "Commands:"
echo " start Start all services"
echo " stop Stop all services"
echo " restart Restart all services"
echo " logs Show logs for all services"
echo " logs [svc] Show logs for specific service"
echo " status Show status of all services"
echo " backup Create database backup"
echo " restore Restore database from backup"
echo " update Update application (pull, build, restart)"
echo " clean Clean up unused Docker resources"
echo " shell [svc] Open shell in service container"
echo " db Connect to database"
echo " help Show this help message"
echo ""
echo "Services: scriptshare-db, scriptshare-api, scriptshare-frontend, scriptshare-proxy, scriptshare-redis"
}
case "$1" in
start)
echo "🚀 Starting ScriptShare services..."
docker-compose -f "$COMPOSE_FILE" up -d
echo "✅ Services started"
;;
stop)
echo "🛑 Stopping ScriptShare services..."
docker-compose -f "$COMPOSE_FILE" down
echo "✅ Services stopped"
;;
restart)
echo "🔄 Restarting ScriptShare services..."
docker-compose -f "$COMPOSE_FILE" restart
echo "✅ Services restarted"
;;
logs)
if [ -n "$2" ]; then
echo "📋 Showing logs for $2..."
docker-compose -f "$COMPOSE_FILE" logs -f "$2"
else
echo "📋 Showing logs for all services..."
docker-compose -f "$COMPOSE_FILE" logs -f
fi
;;
status)
echo "📊 Service Status:"
docker-compose -f "$COMPOSE_FILE" ps
echo ""
echo "🏥 Health Status:"
for service in scriptshare-db scriptshare-api scriptshare-frontend scriptshare-proxy; do
health=$(docker inspect --format='{{.State.Health.Status}}' "$service" 2>/dev/null || echo "not found")
echo " $service: $health"
done
;;
backup)
echo "🗄️ Creating database backup..."
./scripts/backup.sh
;;
restore)
if [ -z "$2" ]; then
echo "❌ Please specify backup file to restore"
echo "Usage: $0 restore <backup-file>"
exit 1
fi
echo "🔄 Restoring database from $2..."
# Implementation for restore would go here
echo "⚠️ Restore functionality not yet implemented"
;;
update)
echo "🔄 Updating ScriptShare application..."
docker-compose -f "$COMPOSE_FILE" pull
docker-compose -f "$COMPOSE_FILE" build --no-cache
docker-compose -f "$COMPOSE_FILE" up -d
echo "✅ Application updated"
;;
clean)
echo "🧹 Cleaning up Docker resources..."
docker system prune -f
docker volume prune -f
echo "✅ Cleanup completed"
;;
shell)
if [ -z "$2" ]; then
echo "❌ Please specify service name"
echo "Available services: scriptshare-db, scriptshare-api, scriptshare-frontend, scriptshare-proxy"
exit 1
fi
echo "💻 Opening shell in $2..."
docker-compose -f "$COMPOSE_FILE" exec "$2" /bin/sh
;;
db)
echo "🗃️ Connecting to database..."
if [ -f ".env" ]; then
source .env
fi
docker-compose -f "$COMPOSE_FILE" exec scriptshare-db mysql -u "${DB_USER:-scriptshare_user}" -p"${DB_PASSWORD:-ScriptShare_App_2024_Secure!}" "${DB_NAME:-scriptshare}"
;;
help|--help|-h)
show_help
;;
*)
echo "❌ Unknown command: $1"
echo ""
show_help
exit 1
;;
esac