security: clean repository without media files and sensitive data
- Removed area/ directory with 816MB of media files - Removed sensitive FTP credentials from Git history - Implemented .env.upload system for secure deployments - Added comprehensive .gitignore for future protection This commit represents a clean slate with all sensitive data removed.
This commit is contained in:
20
deployment/scripts/.env.upload.example
Normal file
20
deployment/scripts/.env.upload.example
Normal file
@@ -0,0 +1,20 @@
|
||||
# FTP/SFTP Zugangsdaten für Webspace Upload
|
||||
# Kopiere diese Datei zu .env.upload und trage deine echten Zugangsdaten ein
|
||||
|
||||
# Server-Adresse (ohne http://, nur Hostname)
|
||||
FTP_HOST="dein-server.de"
|
||||
|
||||
# FTP/SFTP Benutzername
|
||||
FTP_USER="dein-username"
|
||||
|
||||
# FTP/SFTP Passwort
|
||||
FTP_PASS="dein-passwort"
|
||||
|
||||
# Pfad auf dem Server (meist /htdocs, /public_html, /www oder /)
|
||||
FTP_PATH="/htdocs"
|
||||
|
||||
# Beispiele für verschiedene Provider:
|
||||
# Strato: FTP_HOST="ftp.strato.de" FTP_PATH="/htdocs"
|
||||
# 1&1: FTP_HOST="ftp.1und1.de" FTP_PATH="/htdocs"
|
||||
# All-Inkl: FTP_HOST="ftp.all-inkl.com" FTP_PATH="/"
|
||||
# Hetzner: FTP_HOST="deine-domain.de" FTP_PATH="/httpdocs"
|
||||
107
deployment/scripts/README.md
Normal file
107
deployment/scripts/README.md
Normal file
@@ -0,0 +1,107 @@
|
||||
# Deployment Scripts
|
||||
|
||||
Diese Verzeichnis enthält alle Scripts für das Deployment der AdsPreview React Anwendung.
|
||||
|
||||
## 📁 Scripts Übersicht
|
||||
|
||||
### `setup.sh` - Initiales Setup
|
||||
```bash
|
||||
./setup.sh
|
||||
```
|
||||
- Installiert Frontend Dependencies
|
||||
- Erstellt Development Build zum Testen
|
||||
- Bereitet Backend-Verzeichnisse vor
|
||||
- Erstellt Standard-Konfigurationsdateien
|
||||
|
||||
### `deploy.sh` - Production Deployment
|
||||
```bash
|
||||
./deploy.sh
|
||||
```
|
||||
- Erstellt optimierten Production Build
|
||||
- Kopiert alle notwendigen Dateien nach `deployment/build/`
|
||||
- Setzt korrekte Dateiberechtigungen
|
||||
- Bereitet Upload-ready Struktur vor
|
||||
|
||||
### `upload.sh` - Webspace Upload
|
||||
```bash
|
||||
# WICHTIG: Erst .env.upload konfigurieren!
|
||||
cp .env.upload.example .env.upload
|
||||
# Bearbeite .env.upload mit deinen FTP-Zugangsdaten
|
||||
./upload.sh
|
||||
```
|
||||
- Uploaded `deployment/build/` Inhalt via SFTP/FTP
|
||||
- **🔒 SICHER:** Verwendet .env.upload für Zugangsdaten (nicht in Git!)
|
||||
- Benötigt `lftp` Tool (`brew install lftp`)
|
||||
|
||||
## 🚀 Deployment Workflow
|
||||
|
||||
1. **Einmalig:** Setup ausführen
|
||||
```bash
|
||||
cd deployment/scripts
|
||||
./setup.sh
|
||||
```
|
||||
|
||||
2. **FTP-Zugangsdaten konfigurieren (einmalig):**
|
||||
```bash
|
||||
cp .env.upload.example .env.upload
|
||||
# Bearbeite .env.upload mit deinen echten Zugangsdaten
|
||||
```
|
||||
|
||||
3. **Production Build erstellen:**
|
||||
```bash
|
||||
./deploy.sh
|
||||
```
|
||||
|
||||
4. **Auf Webspace hochladen:**
|
||||
```bash
|
||||
./upload.sh
|
||||
```
|
||||
|
||||
## 📦 Deployment-Struktur
|
||||
|
||||
Nach `deploy.sh` wird folgende Struktur erstellt:
|
||||
|
||||
```
|
||||
deployment/build/
|
||||
├── public/ # React App + PHP Entry Points
|
||||
│ ├── index.html # React SPA
|
||||
│ ├── index.php # PHP Backend Entry
|
||||
│ ├── files.php # File Service
|
||||
│ └── static/ # React Assets (CSS, JS)
|
||||
├── src/ # PHP Backend Code
|
||||
│ ├── Api/ # API Controllers
|
||||
│ ├── Core/ # Application Core
|
||||
│ ├── Helper/ # Utility Functions
|
||||
│ └── Services/ # Business Logic
|
||||
├── storage/ # Application Data
|
||||
│ └── data/ # JSON Storage Files
|
||||
└── vendor/ # PHP Dependencies (GetID3)
|
||||
```
|
||||
|
||||
## <20> Sicherheitshinweise
|
||||
|
||||
### FTP-Zugangsdaten (.env.upload)
|
||||
- **NIEMALS** Zugangsdaten direkt ins Script schreiben
|
||||
- **IMMER** .env.upload für sensible Daten verwenden
|
||||
- .env.upload ist automatisch von Git ausgeschlossen
|
||||
- Template: .env.upload.example zeigt die Struktur
|
||||
|
||||
```bash
|
||||
# .env.upload Beispiel:
|
||||
FTP_HOST="dein-server.de"
|
||||
FTP_USER="dein-username"
|
||||
FTP_PASS="dein-passwort"
|
||||
FTP_PATH="/htdocs"
|
||||
```
|
||||
|
||||
## 🔧 Anpassungen
|
||||
|
||||
### nginx Konfiguration
|
||||
Siehe `../nginx/` Verzeichnis für Server-Konfiguration.
|
||||
|
||||
## 💡 Tipps
|
||||
|
||||
- **Scripts laufen von überall:** Die Scripts erkennen automatisch ihren Standort
|
||||
- **Backup:** Sichere vor Upload immer deine Live-Daten
|
||||
- **Testing:** Teste zuerst mit `setup.sh` bevor du `deploy.sh` verwendest
|
||||
- **Logs:** Scripts geben detaillierte Status-Informationen aus
|
||||
97
deployment/scripts/deploy.sh
Executable file
97
deployment/scripts/deploy.sh
Executable file
@@ -0,0 +1,97 @@
|
||||
#!/bin/sh
|
||||
# Deployment-Skript für Production Update
|
||||
|
||||
echo "🚀 Starte Production Deployment..."
|
||||
|
||||
# Prüfe ob wir im deployment/scripts/ Ordner sind und wechsle zur Projekt-Root
|
||||
if [ "$(basename "$PWD")" = "scripts" ]; then
|
||||
cd ../..
|
||||
elif [ "$(basename "$PWD")" = "deployment" ]; then
|
||||
cd ..
|
||||
fi
|
||||
|
||||
# Deployment-Ordner vorbereiten
|
||||
echo "📁 Erstelle Deployment-Ordner..."
|
||||
rm -rf deployment/build 2>/dev/null || true
|
||||
mkdir -p deployment/build/public
|
||||
|
||||
# Frontend bauen
|
||||
echo "📦 Baue Frontend..."
|
||||
cd frontend
|
||||
|
||||
# Temporären Build-Ordner erstellen
|
||||
echo "📁 Erstelle temporären Build-Ordner..."
|
||||
rm -rf ../build_temp 2>/dev/null || true
|
||||
mkdir -p ../build_temp
|
||||
|
||||
# Abhängigkeiten installieren (ohne die lokalen node_modules zu überschreiben)
|
||||
echo "⬇️ Installiere Production Dependencies..."
|
||||
cp package*.json ../build_temp/
|
||||
cd ../build_temp
|
||||
npm ci --production --silent
|
||||
|
||||
# Source-Code kopieren (ohne node_modules)
|
||||
echo "📄 Kopiere Source-Code..."
|
||||
cd ../frontend
|
||||
cp -r public src ../build_temp/
|
||||
cd ../build_temp
|
||||
|
||||
# Build erstellen
|
||||
echo "🔨 Erstelle Production Build..."
|
||||
npm run build
|
||||
|
||||
# Frontend-Build in public-Ordner des Deployments kopieren
|
||||
echo "📦 Kopiere Frontend-Build ins public-Verzeichnis..."
|
||||
cp -r build/* ../deployment/build/public/
|
||||
|
||||
# Backend-Verzeichnisse in der Root des Deployments erstellen
|
||||
echo "📄 Kopiere Backend-Dateien mit korrekter Struktur..."
|
||||
cd ../backend
|
||||
|
||||
# Kopiere Backend-Verzeichnisse in die Root des Deployment-Ordners (als komplette Ordner)
|
||||
cp -r src ../deployment/build/
|
||||
cp -r storage ../deployment/build/
|
||||
cp -r vendor ../deployment/build/
|
||||
|
||||
# PHP-Dateien aus backend/public in das public-Verzeichnis des Deployments kopieren
|
||||
cd public
|
||||
for file in *.php .htaccess .nginx; do
|
||||
if [ -f "$file" ]; then
|
||||
cp "$file" ../../deployment/build/public/
|
||||
fi
|
||||
done
|
||||
|
||||
# area-Ordner in die Root des Deployment-Ordners kopieren
|
||||
#echo "📁 Kopiere area-Verzeichnis..."
|
||||
#cd ../..
|
||||
#cp -r area deployment/build/ 2>/dev/null || true
|
||||
|
||||
# Temporären Build-Ordner aufräumen
|
||||
echo "🧹 Räume temporären Build-Ordner auf..."
|
||||
cd ../..
|
||||
rm -rf build_temp
|
||||
|
||||
# Rechte setzen
|
||||
echo "🔒 Setze Dateiberechtigungen..."
|
||||
chmod -R 755 deployment/build
|
||||
find deployment/build -type f -name "*.html" -exec chmod 644 {} \;
|
||||
find deployment/build -type f -name "*.css" -exec chmod 644 {} \;
|
||||
find deployment/build -type f -name "*.js" -exec chmod 644 {} \;
|
||||
find deployment/build -type f -name "*.php" -exec chmod 644 {} \;
|
||||
find deployment/build -type f -name "*.json" -exec chmod 644 {} \;
|
||||
|
||||
echo "✅ Production Deployment abgeschlossen!"
|
||||
echo "🎯 Deployment-ready Dateien sind im 'deployment/build/' Ordner"
|
||||
echo ""
|
||||
echo "📋 DEPLOYMENT STRUKTUR:"
|
||||
echo " deployment/build/"
|
||||
echo " ├── public/ (React App + PHP Entry Points)"
|
||||
echo " │ ├── index.html (React)"
|
||||
echo " │ ├── index.php (PHP Entry Point)"
|
||||
echo " │ └── static/ (React Assets)"
|
||||
echo " ├── src/ (PHP Backend Code)"
|
||||
echo " ├── storage/ (Data Files)"
|
||||
echo " ├── vendor/ (PHP Dependencies)"
|
||||
echo " └── area/ (Project Data)"
|
||||
echo ""
|
||||
echo "📤 Du kannst jetzt den kompletten Inhalt des 'deployment/build/' Ordners auf deinen Webspace hochladen."
|
||||
52
deployment/scripts/setup.sh
Executable file
52
deployment/scripts/setup.sh
Executable file
@@ -0,0 +1,52 @@
|
||||
#!/bin/sh
|
||||
# Setup-Skript für initiales Deployment
|
||||
|
||||
echo "🔧 Starte initiales Setup..."
|
||||
|
||||
# Prüfe ob wir im deployment/scripts/ Ordner sind und wechsle zur Projekt-Root
|
||||
if [ "$(basename "$PWD")" = "scripts" ]; then
|
||||
cd ../..
|
||||
elif [ "$(basename "$PWD")" = "deployment" ]; then
|
||||
cd ..
|
||||
fi
|
||||
|
||||
# Dependencies installieren
|
||||
echo "📦 Installiere Frontend Dependencies..."
|
||||
cd frontend
|
||||
npm install
|
||||
|
||||
# Development Build für Testing
|
||||
echo "🛠️ Erstelle Development Build..."
|
||||
npm run build
|
||||
|
||||
# Build ins Backend kopieren
|
||||
echo "📁 Kopiere Build-Dateien..."
|
||||
cp -r build/* ../backend/public/
|
||||
|
||||
# Rechte setzen
|
||||
echo "🔒 Setze Dateiberechtigungen..."
|
||||
chmod -R 755 ../backend/public
|
||||
|
||||
# Erstelle notwendige Verzeichnisse
|
||||
echo "📂 Erstelle Backend-Verzeichnisse..."
|
||||
mkdir -p ../backend/storage/data
|
||||
chmod 755 ../backend/storage
|
||||
chmod 755 ../backend/storage/data
|
||||
|
||||
# Erstelle Standard-Konfigurationsdateien falls nicht vorhanden
|
||||
cd ../backend/storage/data
|
||||
if [ ! -f "admins.json" ]; then
|
||||
echo '[]' > admins.json
|
||||
chmod 644 admins.json
|
||||
fi
|
||||
if [ ! -f "viewers.json" ]; then
|
||||
echo '[]' > viewers.json
|
||||
chmod 644 viewers.json
|
||||
fi
|
||||
if [ ! -f "clients.json" ]; then
|
||||
echo '[]' > clients.json
|
||||
chmod 644 clients.json
|
||||
fi
|
||||
|
||||
echo "✅ Setup abgeschlossen!"
|
||||
echo "📝 Konfiguriere nun deine Benutzer in backend/storage/data/"
|
||||
90
deployment/scripts/upload.sh
Executable file
90
deployment/scripts/upload.sh
Executable file
@@ -0,0 +1,90 @@
|
||||
#!/bin/sh
|
||||
# Upload-Skript für Webspace Deployment
|
||||
|
||||
echo "📤 Webspace Upload Skript"
|
||||
echo ""
|
||||
|
||||
# Konfiguration aus .env.upload Datei laden
|
||||
ENV_FILE="$(dirname "$0")/.env.upload"
|
||||
|
||||
if [ ! -f "$ENV_FILE" ]; then
|
||||
echo "❌ Konfigurationsdatei nicht gefunden: $ENV_FILE"
|
||||
echo ""
|
||||
echo "📋 ERSTELLE EINE .env.upload DATEI:"
|
||||
echo " 1. Kopiere .env.upload.example zu .env.upload"
|
||||
echo " 2. Trage deine FTP-Zugangsdaten ein"
|
||||
echo ""
|
||||
echo " Beispiel:"
|
||||
echo " FTP_HOST=\"dein-server.de\""
|
||||
echo " FTP_USER=\"dein-username\""
|
||||
echo " FTP_PASS=\"dein-passwort\""
|
||||
echo " FTP_PATH=\"/htdocs\""
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Environment-Variablen aus .env.upload laden
|
||||
set -a # Export aller Variablen
|
||||
source "$ENV_FILE"
|
||||
set +a
|
||||
|
||||
echo "🔧 KONFIGURATION:"
|
||||
echo " Host: $FTP_HOST"
|
||||
echo " User: $FTP_USER"
|
||||
echo " Path: $FTP_PATH"
|
||||
echo ""
|
||||
|
||||
# Prüfe ob wir im deployment/scripts/ Ordner sind und wechsle zur Projekt-Root
|
||||
if [ "$(basename "$PWD")" = "scripts" ]; then
|
||||
cd ../..
|
||||
elif [ "$(basename "$PWD")" = "deployment" ]; then
|
||||
cd ..
|
||||
fi
|
||||
|
||||
# Überprüfe ob deployment/build Ordner existiert
|
||||
if [ ! -d "deployment/build" ]; then
|
||||
echo "❌ deployment/build/ Ordner nicht gefunden."
|
||||
echo " Führe zuerst das deploy.sh Skript aus!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Überprüfe ob lftp installiert ist
|
||||
if ! command -v lftp &> /dev/null; then
|
||||
echo "❌ lftp ist nicht installiert."
|
||||
echo " Installation: brew install lftp"
|
||||
echo ""
|
||||
echo "📋 MANUELLE UPLOAD-ANLEITUNG:"
|
||||
echo " 1. Öffne deinen FTP Client (FileZilla, etc.)"
|
||||
echo " 2. Verbinde zu deinem Webspace"
|
||||
echo " 3. Navigiere zu htdocs/ oder public_html/"
|
||||
echo " 4. Uploade alle Dateien aus: deployment/build/"
|
||||
echo ""
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "⚠️ ACHTUNG: Dies überschreibt alle Dateien auf dem Webspace!"
|
||||
echo " Fortfahren? (y/N)"
|
||||
read -r response
|
||||
if [[ ! "$response" =~ ^[Yy]$ ]]; then
|
||||
echo "Abgebrochen."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "📤 Uploade via SFTP..."
|
||||
lftp -c "
|
||||
set sftp:auto-confirm yes;
|
||||
set ssl:verify-certificate no;
|
||||
open sftp://$FTP_USER:$FTP_PASS@$FTP_HOST;
|
||||
cd $FTP_PATH;
|
||||
|
||||
lcd deployment/build;
|
||||
mirror --reverse --delete --verbose --exclude-glob=node_modules/ --exclude-glob=.git/ --exclude-glob=.* --exclude area/ ./ ./;
|
||||
|
||||
bye
|
||||
"
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "✅ Upload erfolgreich!"
|
||||
echo "🌐 Deine App sollte jetzt live sein!"
|
||||
else
|
||||
echo "❌ Upload fehlgeschlagen. Prüfe deine FTP-Zugangsdaten."
|
||||
fi
|
||||
Reference in New Issue
Block a user