Files
digiserver-v2/old_code_documentation/clean_for_deployment.sh
DigiServer Admin 4a9616a0f7 Add HTTPS support with Caddy and clean up legacy files
- Add Caddy reverse proxy for automatic HTTPS with Let's Encrypt
- Update docker-compose.yml with Caddy service and internal networking
- Remove all Redis dependencies (not needed for this deployment)
- Fix Dockerfile permissions for instance and uploads directories
- Move legacy scripts to old_code_documentation folder
  - add_muted_column.py, check_fix_player.py, migrate_add_edit_enabled.py
  - docker-start.sh, run_dev.sh, start.sh, clean_for_deployment.sh
- Add HTTPS_SETUP.md documentation for Caddy configuration
- Update .env.example with DOMAIN and EMAIL variables
- Remove redis package from requirements.txt
- Remove rate limiting Redis storage from config.py
2025-12-11 16:56:44 +02:00

94 lines
2.7 KiB
Bash
Executable File
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# Clean development data before Docker deployment
# This script removes all development data to ensure a fresh start
set -e
# Get the root directory of the application
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
APP_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
echo "🧹 Cleaning DigiServer v2 for deployment..."
echo "📍 App root: $APP_ROOT"
echo ""
# Confirm action
read -p "This will delete ALL data (database, uploads, logs). Continue? (y/N): " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "❌ Cancelled"
exit 1
fi
echo ""
echo "📦 Cleaning development data..."
# Change to app root directory
cd "$APP_ROOT"
# Remove database files
if [ -d "instance" ]; then
echo " 🗄️ Removing database files..."
rm -rf instance/*.db
rm -rf instance/*.db-*
echo " ✅ Database cleaned"
else
echo " No instance directory found"
fi
# Remove uploaded media
if [ -d "app/static/uploads" ]; then
echo " 📁 Removing uploaded media files..."
find app/static/uploads -type f -not -name '.gitkeep' -delete 2>/dev/null || true
find app/static/uploads -type d -empty -not -path "app/static/uploads" -delete 2>/dev/null || true
echo " ✅ Uploads cleaned"
else
echo " No uploads directory found"
fi
# Remove additional upload directory if exists
if [ -d "static/uploads" ]; then
echo " 📁 Removing static uploads..."
find static/uploads -type f -not -name '.gitkeep' -delete 2>/dev/null || true
find static/uploads -type d -empty -not -path "static/uploads" -delete 2>/dev/null || true
echo " ✅ Static uploads cleaned"
fi
# Remove log files
echo " 📝 Removing log files..."
find . -name "*.log" -type f -delete 2>/dev/null || true
echo " ✅ Logs cleaned"
# Remove Python cache
echo " 🐍 Removing Python cache..."
find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true
find . -type f -name "*.pyc" -delete 2>/dev/null || true
find . -type f -name "*.pyo" -delete 2>/dev/null || true
echo " ✅ Python cache cleaned"
# Remove Flask session files if any
if [ -d "flask_session" ]; then
echo " 🔐 Removing session files..."
rm -rf flask_session
echo " ✅ Sessions cleaned"
fi
# Summary
echo ""
echo "✨ Cleanup complete!"
echo ""
echo "📊 Summary:"
echo " - Database: Removed"
echo " - Uploaded media: Removed"
echo " - Logs: Removed"
echo " - Python cache: Removed"
echo ""
echo "🚀 Ready for deployment!"
echo ""
echo "Next steps:"
echo " 1. Build Docker image: docker compose build"
echo " 2. Start container: docker compose up -d"
echo " 3. Access at: http://localhost:80"
echo " 4. Login with: admin / admin123"
echo ""