Deployment-Skript: Erstellt saubere Kopie für Server-Upload
Neues Skript prepare-deploy.sh das eine Kopie des Projekts erstellt und für einen Clean Install vorbereitet (ohne das Original zu verändern): - Entfernt storage/installed, setup-token, Datenbank, Logs, Caches - Setzt .env auf .env.example zurück - Behält vendor/ (kein SSH nötig) - Exkludiert .git, .claude, node_modules Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
103
prepare-deploy.sh
Executable file
103
prepare-deploy.sh
Executable file
@@ -0,0 +1,103 @@
|
||||
#!/bin/bash
|
||||
# ============================================================
|
||||
# Deployment-Vorbereitung: Erstellt eine saubere Kopie für
|
||||
# den Upload auf einen Webserver (Clean Install).
|
||||
#
|
||||
# WICHTIG: Dieses Skript verändert NICHT das aktuelle Projekt!
|
||||
# Es arbeitet ausschließlich auf einer Kopie.
|
||||
# ============================================================
|
||||
|
||||
set -e
|
||||
|
||||
# Farben für Ausgabe
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
RED='\033[0;31m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Quellverzeichnis = Verzeichnis dieses Skripts
|
||||
SOURCE_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
|
||||
DEPLOY_DIR="${SOURCE_DIR}/../WebApp_Deploy_${TIMESTAMP}"
|
||||
|
||||
echo ""
|
||||
echo "============================================"
|
||||
echo " Deployment-Vorbereitung"
|
||||
echo "============================================"
|
||||
echo ""
|
||||
echo -e "Quelle: ${YELLOW}${SOURCE_DIR}${NC}"
|
||||
echo -e "Ziel: ${YELLOW}${DEPLOY_DIR}${NC}"
|
||||
echo ""
|
||||
|
||||
# ---- 1. Kopie erstellen (ohne .git, .claude, node_modules) ----
|
||||
echo -e "${GREEN}[1/6]${NC} Erstelle Kopie des Projekts..."
|
||||
rsync -a \
|
||||
--exclude='.git' \
|
||||
--exclude='.claude' \
|
||||
--exclude='node_modules' \
|
||||
--exclude='.phpunit.cache' \
|
||||
--exclude='.idea' \
|
||||
--exclude='.vscode' \
|
||||
--exclude='.fleet' \
|
||||
"${SOURCE_DIR}/" "${DEPLOY_DIR}/"
|
||||
echo " Kopie erstellt."
|
||||
|
||||
# ---- 2. Installationsmarker entfernen ----
|
||||
echo -e "${GREEN}[2/6]${NC} Entferne Installationsmarker..."
|
||||
rm -f "${DEPLOY_DIR}/storage/installed"
|
||||
rm -f "${DEPLOY_DIR}/storage/setup-token"
|
||||
echo " storage/installed und storage/setup-token entfernt."
|
||||
|
||||
# ---- 3. Datenbank entfernen ----
|
||||
echo -e "${GREEN}[3/6]${NC} Entferne Datenbank..."
|
||||
rm -f "${DEPLOY_DIR}/database/database.sqlite"
|
||||
echo " database/database.sqlite entfernt."
|
||||
|
||||
# ---- 4. Logs und Caches leeren ----
|
||||
echo -e "${GREEN}[4/6]${NC} Leere Logs und Caches..."
|
||||
# Logs
|
||||
rm -f "${DEPLOY_DIR}/storage/logs/"*.log
|
||||
# Compiled Views
|
||||
rm -f "${DEPLOY_DIR}/storage/framework/views/"*.php
|
||||
# Cache-Dateien
|
||||
find "${DEPLOY_DIR}/storage/framework/cache/" -type f ! -name '.gitignore' -delete 2>/dev/null || true
|
||||
# Sessions
|
||||
find "${DEPLOY_DIR}/storage/framework/sessions/" -type f ! -name '.gitignore' -delete 2>/dev/null || true
|
||||
# Bootstrap Cache
|
||||
rm -f "${DEPLOY_DIR}/bootstrap/cache/packages.php"
|
||||
rm -f "${DEPLOY_DIR}/bootstrap/cache/services.php"
|
||||
rm -f "${DEPLOY_DIR}/bootstrap/cache/config.php"
|
||||
rm -f "${DEPLOY_DIR}/bootstrap/cache/routes-v7.php"
|
||||
echo " Logs, Views, Cache und Sessions geleert."
|
||||
|
||||
# ---- 5. .env zurücksetzen ----
|
||||
echo -e "${GREEN}[5/6]${NC} Setze .env auf Vorlage zurück..."
|
||||
cp "${DEPLOY_DIR}/.env.example" "${DEPLOY_DIR}/.env"
|
||||
echo " .env = .env.example (APP_KEY leer, wird beim Install generiert)."
|
||||
|
||||
# ---- 6. Deployment-Skript selbst entfernen ----
|
||||
echo -e "${GREEN}[6/6]${NC} Entferne Deployment-Skript aus der Kopie..."
|
||||
rm -f "${DEPLOY_DIR}/prepare-deploy.sh"
|
||||
echo " prepare-deploy.sh aus Kopie entfernt."
|
||||
|
||||
# ---- Zusammenfassung ----
|
||||
echo ""
|
||||
echo "============================================"
|
||||
echo -e " ${GREEN}Fertig!${NC}"
|
||||
echo "============================================"
|
||||
echo ""
|
||||
echo "Der Deploy-Ordner ist bereit:"
|
||||
echo -e " ${YELLOW}${DEPLOY_DIR}${NC}"
|
||||
echo ""
|
||||
echo "Nächste Schritte:"
|
||||
echo " 1. Ordner per FTP auf den Webserver hochladen"
|
||||
echo " 2. public/ als Document Root konfigurieren"
|
||||
echo " 3. Im Browser aufrufen → Installer startet automatisch"
|
||||
echo ""
|
||||
echo -e "${YELLOW}Hinweis:${NC} Der vendor/-Ordner ist enthalten (kein SSH nötig)."
|
||||
echo ""
|
||||
|
||||
# Größe anzeigen
|
||||
DEPLOY_SIZE=$(du -sh "${DEPLOY_DIR}" | cut -f1)
|
||||
echo -e "Ordner-Größe: ${DEPLOY_SIZE}"
|
||||
echo ""
|
||||
Reference in New Issue
Block a user