Docker deployment improvements: fixed backup/restore, sticky headers, quality code display

This commit is contained in:
ske087
2025-11-13 02:40:36 +02:00
parent 3b69161f1e
commit 2ce918e1b3
13 changed files with 1034 additions and 117 deletions

185
quick-deploy.sh Normal file
View File

@@ -0,0 +1,185 @@
#!/bin/bash
# ============================================================================
# Quick Deployment Script for Quality Application
# Handles setup, build, and deployment in one command
# ============================================================================
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
# Logging functions
log_info() {
echo -e "${BLUE} INFO:${NC} $*"
}
log_success() {
echo -e "${GREEN}✅ SUCCESS:${NC} $*"
}
log_warning() {
echo -e "${YELLOW}⚠️ WARNING:${NC} $*"
}
log_error() {
echo -e "${RED}❌ ERROR:${NC} $*" >&2
}
# ============================================================================
# Functions
# ============================================================================
check_dependencies() {
log_info "Checking dependencies..."
if ! command -v docker &> /dev/null; then
log_error "Docker is not installed. Please install Docker first."
exit 1
fi
if ! command -v docker-compose &> /dev/null; then
log_error "docker-compose is not installed. Please install docker-compose first."
exit 1
fi
log_success "Dependencies check passed"
}
setup_environment() {
log_info "Setting up environment..."
# Create directories
bash setup-volumes.sh
# Check for .env file
if [ ! -f ".env" ]; then
log_warning ".env file not found, creating from example..."
cp .env.example .env
log_warning "Please edit .env file and set your passwords and configuration!"
log_warning "Press CTRL+C to cancel or ENTER to continue with default values (NOT RECOMMENDED FOR PRODUCTION)"
read -r
fi
log_success "Environment setup complete"
}
build_images() {
log_info "Building Docker images..."
docker-compose build --no-cache
log_success "Docker images built successfully"
}
start_services() {
log_info "Starting services..."
docker-compose up -d
log_success "Services started"
}
show_status() {
echo ""
echo "============================================================================"
echo "📊 Service Status"
echo "============================================================================"
docker-compose ps
echo ""
}
show_logs() {
log_info "Showing recent logs (press CTRL+C to exit)..."
sleep 2
docker-compose logs -f --tail=50
}
# ============================================================================
# Main Deployment
# ============================================================================
main() {
echo "============================================================================"
echo "🚀 Quality Application - Quick Deployment"
echo "============================================================================"
echo ""
# Parse arguments
BUILD_ONLY=false
SKIP_LOGS=false
while [[ $# -gt 0 ]]; do
case $1 in
--build-only)
BUILD_ONLY=true
shift
;;
--skip-logs)
SKIP_LOGS=true
shift
;;
--help)
echo "Usage: $0 [OPTIONS]"
echo ""
echo "Options:"
echo " --build-only Only build images, don't start services"
echo " --skip-logs Don't show logs after deployment"
echo " --help Show this help message"
echo ""
exit 0
;;
*)
log_error "Unknown option: $1"
echo "Use --help for usage information"
exit 1
;;
esac
done
# Check if we're in the right directory
if [ ! -f "docker-compose.yml" ]; then
log_error "docker-compose.yml not found. Please run this script from the application root directory."
exit 1
fi
# Execute deployment steps
check_dependencies
setup_environment
build_images
if [ "$BUILD_ONLY" = true ]; then
log_success "Build complete! Use 'docker-compose up -d' to start services."
exit 0
fi
start_services
show_status
echo "============================================================================"
echo "✅ Deployment Complete!"
echo "============================================================================"
echo ""
echo "Application URL: http://localhost:8781"
echo "Database Port: 3306 (accessible from host)"
echo ""
echo "Useful commands:"
echo " View logs: docker-compose logs -f web"
echo " Stop services: docker-compose down"
echo " Restart: docker-compose restart"
echo " Database shell: docker-compose exec db mysql -u trasabilitate -p"
echo ""
echo "Volume locations:"
echo " Database: ./data/mariadb/"
echo " Configuration: ./config/instance/"
echo " Logs: ./logs/"
echo " Backups: ./backups/"
echo ""
if [ "$SKIP_LOGS" = false ]; then
show_logs
fi
}
# Run main function
main "$@"