# 🚀 GoLapApp Deployment Guide

## 📋 Inhaltsverzeichnis
1. [Server Vorbereitung (Debian 12)](#server-vorbereitung)
2. [Web-App Deployment](#web-app-deployment)
3. [iOS IPA Erstellung](#ios-ipa-erstellung)
4. [App Icon Integration](#app-icon-integration)
5. [Troubleshooting](#troubleshooting)

---

## 🖥️ Server Vorbereitung (Debian 12)

### 1. Server Setup ausführen
```bash
# Auf deinem Debian 12 Server:
wget https://your-domain.com/server-setup.sh
chmod +x server-setup.sh
./server-setup.sh
```

### 2. Benötigte Software (wird automatisch installiert):
- ✅ Node.js 20.x (LTS)
- ✅ NPM
- ✅ Nginx
- ✅ PM2 (Prozess Manager)
- ✅ Certbot (SSL)
- ✅ Firewall (UFW)

### 3. Manuel Installation (falls Skript fehlschlägt):
```bash
# System aktualisieren
sudo apt update && sudo apt upgrade -y

# Node.js 20.x
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt-get install -y nodejs

# PM2
sudo npm install -g pm2

# Nginx
sudo apt install -y nginx

# Firewall
sudo ufw allow ssh
sudo ufw allow 'Nginx Full'
sudo ufw --force enable
```

---

## 🌐 Web-App Deployment

### 1. Web Build erstellen
```bash
# Auf deinem lokalen Mac:
cd /Users/atakanozkan/GoLapApp
chmod +x deploy/build-web.sh
./deploy/build-web.sh
```

### 2. Dateien auf Server kopieren
```bash
# Ersetze YOUR_SERVER_IP mit deiner Server-IP
scp -r web-build/* user@YOUR_SERVER_IP:/var/www/golapapp/web/
scp deploy/nginx-golapapp.conf user@YOUR_SERVER_IP:/etc/nginx/sites-available/
scp deploy/ecosystem.config.js user@YOUR_SERVER_IP:/var/www/golapapp/
```

### 3. Auf Server konfigurieren
```bash
# Nginx konfigurieren
sudo ln -s /etc/nginx/sites-available/nginx-golapapp.conf /etc/nginx/sites-enabled/
sudo rm /etc/nginx/sites-enabled/default
sudo nginx -t
sudo systemctl reload nginx

# Backend starten
cd /var/www/golapapp
npm install
pm2 start ecosystem.config.js
pm2 save
pm2 startup
```

### 4. SSL Zertifikat (optional)
```bash
# Ersetze your-domain.com mit deiner Domain
sudo certbot --nginx -d your-domain.com
```

---

## 📱 iOS IPA Erstellung

### 1. Voraussetzungen auf deinem Mac:
- ✅ Xcode (von App Store)
- ✅ Apple Developer Account ($99/Jahr)
- ✅ EAS CLI: `npm install -g eas-cli`

### 2. App Icon vorbereiten
```bash
cd /Users/atakanozkan/GoLapApp
chmod +x deploy/setup-icons.sh
./deploy/setup-icons.sh

# Platziere dein Icon (1024x1024) als assets/icon.png
```

### 3. iOS Build erstellen
```bash
cd /Users/atakanozkan/GoLapApp
chmod +x deploy/build-ios.sh
./deploy/build-ios.sh

# Folge den Anweisungen in der Konsole
# Die IPA-Datei wird in der EAS Console zum Download bereitgestellt
```

### 4. IPA auf iPhone installieren
1. **EAS Console**: Lade die IPA-Datei herunter
2. **AltStore**: Installiere AltStore auf deinem iPhone
3. **Sideload**: Öffne die IPA-Datei mit AltStore
4. **Trust**: Gehe zu Settings > General > VPN & Device Management und vertraue der App

---

## 🎨 App Icon Integration

### Benötigte Icon-Größen:
```
assets/
├── icon.png (1024x1024) - Haupt-Icon
├── adaptive-icon.png (1024x1024) - Android Adaptive
├── splash.png (1242x2436) - Splash Screen
└── favicon.png (32x32) - Web Favicon
```

### Automatische Konvertierung:
```bash
./deploy/convert-icons.sh
```

---

## 🔧 Troubleshooting

### Server Probleme:
```bash
# Nginx Status prüfen
sudo systemctl status nginx

# PM2 Status prüfen
pm2 status
pm2 logs

# Firewall Status
sudo ufw status

# Ports prüfen
sudo netstat -tlnp | grep :80
sudo netstat -tlnp | grep :3001
```

### iOS Build Probleme:
```bash
# EAS CLI aktualisieren
npm update -g eas-cli

# Expo Projekt reset
npx expo install --fix

# Cache leeren
npx expo start --clear
```

### Web Build Probleme:
```bash
# Dependencies prüfen
npm install

# Expo CLI aktualisieren
npm update -g @expo/cli

# Build erzwingen
npx expo export --platform web --clear
```

---

## 📞 Support

### Nützliche Links:
- [EAS Documentation](https://docs.expo.dev/build/introduction/)
- [Expo Router](https://docs.expo.dev/router/introduction/)
- [AltStore](https://altstore.io/)
- [Nginx Documentation](https://nginx.org/en/docs/)

### Häufige Fehler:
1. **"Cannot find module"**: `npm install` ausführen
2. **"Permission denied"**: `chmod +x` für Skripte
3. **"Port already in use"**: `sudo lsof -i :3001`
4. **"Build failed"**: Xcode und Apple Developer Account prüfen

---

## ✅ Checkliste vor Deployment

### Server:
- [ ] Debian 12 aktualisiert
- [ ] Node.js 20.x installiert
- [ ] Nginx konfiguriert
- [ ] Firewall eingerichtet
- [ ] PM2 installiert

### Web-App:
- [ ] Build erfolgreich
- [ ] API-Endpunkte angepasst
- [ ] SSL-Zertifikat (optional)
- [ ] Backend läuft

### iOS:
- [ ] App Icon vorhanden
- [ ] Apple Developer Account aktiv
- [ ] EAS CLI installiert
- [ ] Build erfolgreich

---

**🎉 Viel Erfolg beim Deployment!**
