287 lines
7.5 KiB
Markdown
287 lines
7.5 KiB
Markdown
# Remote Development Setup - Mac → Linux Server
|
|
|
|
## 🔄 Entwicklungsworkflow: Mac Entwicklung → Linux Testing
|
|
|
|
Optimaler Workflow für Entwicklung auf Mac mit Testing auf Linux-Server, der der späteren Produktionsumgebung entspricht.
|
|
|
|
## 🚀 Quick Start
|
|
|
|
### **Auf dem Linux-Server (via SSH):**
|
|
```bash
|
|
# 1. Repository klonen (falls nicht geschehen)
|
|
git clone https://github.com/your-repo/rezepte.git
|
|
cd rezepte
|
|
|
|
# 2. Development-Umgebung einrichten
|
|
./setup-development.sh
|
|
|
|
# 3. Entwicklungsumgebung starten
|
|
./start-development.sh
|
|
```
|
|
|
|
### **Von deinem Mac aus zugreifen:**
|
|
```bash
|
|
# Option 1: Direkter Zugriff (wenn Server öffentlich)
|
|
http://SERVER_IP:3000
|
|
|
|
# Option 2: SSH-Tunnel (sicherer)
|
|
ssh -L 3000:localhost:3000 -L 3001:localhost:3001 -L 8080:localhost:8080 user@server
|
|
# Dann: http://localhost:3000
|
|
```
|
|
|
|
## 🏗️ Architektur-Übersicht
|
|
|
|
### **Development-Pipeline:**
|
|
```
|
|
┌─────────────┐ ┌─────────────────┐ ┌──────────────────┐
|
|
│ Mac │ │ Linux Server │ │ Production │
|
|
│ │ │ (Development) │ │ │
|
|
│ VS Code │───▶│ Docker Compose │───▶│ Traefik + SSL │
|
|
│ Git │ │ Direct Ports │ │ Registry Images │
|
|
│ Testing │ │ Hot Reload │ │ External MySQL │
|
|
└─────────────┘ └─────────────────┘ └──────────────────┘
|
|
Local Dev Linux Testing Production Deploy
|
|
```
|
|
|
|
## 🛠️ Development-Umgebung Features
|
|
|
|
### **Was wird automatisch eingerichtet:**
|
|
- ✅ **Linux-spezifische Konfiguration** (IP-Erkennung, Netzwerk)
|
|
- ✅ **Development Docker Compose** (direkte Ports, Hot Reload)
|
|
- ✅ **Eigene MySQL-Instanz** (unabhängig von Production)
|
|
- ✅ **CORS für Remote-Zugriff** konfiguriert
|
|
- ✅ **phpMyAdmin** für Datenbank-Management
|
|
|
|
### **Port-Mapping (alle Interfaces 0.0.0.0):**
|
|
- **Frontend**: `3000:80`
|
|
- **Backend**: `3001:3001`
|
|
- **phpMyAdmin**: `8080:80`
|
|
- **MySQL**: `3307:3306`
|
|
|
|
## 🔧 Entwicklungsworkflows
|
|
|
|
### **1. Code-Sync-Strategien:**
|
|
|
|
#### **A) Git-basiert (empfohlen):**
|
|
```bash
|
|
# Auf Mac: Code ändern und committen
|
|
git add .
|
|
git commit -m "Feature XYZ"
|
|
git push
|
|
|
|
# Auf Server: Pullen und neu builden
|
|
git pull
|
|
docker-compose -f docker-compose.development.yml build frontend
|
|
docker-compose -f docker-compose.development.yml restart frontend
|
|
```
|
|
|
|
#### **B) VS Code Remote-SSH:**
|
|
```bash
|
|
# VS Code Extension installieren: "Remote - SSH"
|
|
# Direkt auf Server entwickeln
|
|
code --remote ssh-remote+user@server /path/to/rezepte
|
|
```
|
|
|
|
#### **C) rsync-Sync:**
|
|
```bash
|
|
# Automatischer Sync von Mac zu Server
|
|
rsync -avz --exclude 'node_modules' ./ user@server:/path/to/rezepte/
|
|
```
|
|
|
|
### **2. Container-Rebuild-Workflows:**
|
|
|
|
#### **Frontend-Änderungen:**
|
|
```bash
|
|
# Auf Server
|
|
docker-compose -f docker-compose.development.yml build frontend
|
|
docker-compose -f docker-compose.development.yml restart frontend
|
|
```
|
|
|
|
#### **Backend-Änderungen:**
|
|
```bash
|
|
# Auf Server
|
|
docker-compose -f docker-compose.development.yml build backend
|
|
docker-compose -f docker-compose.development.yml restart backend
|
|
```
|
|
|
|
#### **Full Rebuild:**
|
|
```bash
|
|
# Auf Server
|
|
docker-compose -f docker-compose.development.yml down
|
|
docker-compose -f docker-compose.development.yml up -d --build
|
|
```
|
|
|
|
## 🔒 Sichere Zugriffsmethoden
|
|
|
|
### **1. SSH-Tunnel (empfohlen für öffentliche Server):**
|
|
```bash
|
|
# Alle Development-Ports tunneln
|
|
ssh -L 3000:localhost:3000 \
|
|
-L 3001:localhost:3001 \
|
|
-L 8080:localhost:8080 \
|
|
-L 3307:localhost:3307 \
|
|
user@your-server.com
|
|
|
|
# Dann lokal zugreifen:
|
|
# Frontend: http://localhost:3000
|
|
# API: http://localhost:3001/api
|
|
# phpMyAdmin: http://localhost:8080
|
|
```
|
|
|
|
### **2. VPN-Zugriff:**
|
|
```bash
|
|
# Wenn Server im VPN/privaten Netzwerk
|
|
http://PRIVATE_SERVER_IP:3000
|
|
```
|
|
|
|
### **3. Firewall-Konfiguration:**
|
|
```bash
|
|
# Auf Server: Ports nur für Development freigeben
|
|
sudo ufw allow from YOUR_MAC_IP to any port 3000
|
|
sudo ufw allow from YOUR_MAC_IP to any port 3001
|
|
sudo ufw allow from YOUR_MAC_IP to any port 8080
|
|
```
|
|
|
|
## 🔄 Kontinuierliche Integration
|
|
|
|
### **Development → Testing → Production Pipeline:**
|
|
|
|
#### **1. Development (Linux Server):**
|
|
```bash
|
|
# Feature entwickeln und testen
|
|
./start-development.sh
|
|
# Test: http://server:3000
|
|
```
|
|
|
|
#### **2. Registry-Build (für Staging):**
|
|
```bash
|
|
# Images für Registry builden
|
|
./build-and-push.sh
|
|
```
|
|
|
|
#### **3. Production-Deployment:**
|
|
```bash
|
|
# Mit fertigen Registry-Images
|
|
./deploy-external-db.sh # Oder ./deploy-traefik.sh
|
|
```
|
|
|
|
## 📊 Monitoring & Debugging
|
|
|
|
### **Live-Logs verfolgen:**
|
|
```bash
|
|
# Alle Services
|
|
docker-compose -f docker-compose.development.yml logs -f
|
|
|
|
# Nur Backend
|
|
docker-compose -f docker-compose.development.yml logs -f backend
|
|
|
|
# Nur Frontend
|
|
docker-compose -f docker-compose.development.yml logs -f frontend
|
|
```
|
|
|
|
### **Container-Status prüfen:**
|
|
```bash
|
|
docker-compose -f docker-compose.development.yml ps
|
|
docker-compose -f docker-compose.development.yml top
|
|
```
|
|
|
|
### **Performance-Monitoring:**
|
|
```bash
|
|
# Resource-Verbrauch
|
|
docker stats
|
|
|
|
# Container-Details
|
|
docker inspect rezepte-backend-dev
|
|
```
|
|
|
|
## 🛠️ Troubleshooting
|
|
|
|
### **Container starten nicht:**
|
|
```bash
|
|
# Logs prüfen
|
|
docker-compose -f docker-compose.development.yml logs
|
|
|
|
# Clean restart
|
|
docker-compose -f docker-compose.development.yml down -v
|
|
docker-compose -f docker-compose.development.yml up -d --build
|
|
```
|
|
|
|
### **Netzwerk-Verbindung fehlschlägt:**
|
|
```bash
|
|
# Server-IP prüfen
|
|
ip addr show
|
|
hostname -I
|
|
|
|
# Firewall-Status
|
|
sudo ufw status
|
|
|
|
# Port-Binding prüfen
|
|
netstat -tlnp | grep :3000
|
|
```
|
|
|
|
### **MySQL-Verbindung fehlschlägt:**
|
|
```bash
|
|
# MySQL-Logs
|
|
docker-compose -f docker-compose.development.yml logs mysql
|
|
|
|
# Direkter MySQL-Zugriff
|
|
docker exec -it rezepte-mysql-dev mysql -uroot -p
|
|
```
|
|
|
|
## 💡 Pro-Tips
|
|
|
|
### **1. Auto-Rebuild bei Änderungen:**
|
|
```bash
|
|
# File-Watcher für automatischen Rebuild
|
|
sudo apt install inotify-tools
|
|
|
|
# Watch-Script erstellen
|
|
#!/bin/bash
|
|
inotifywait -m -r --format '%w %e %f' -e modify ./nodejs-version/ | while read dir event file; do
|
|
echo "File changed: $dir$file"
|
|
if [[ "$dir" == *"frontend"* ]]; then
|
|
docker-compose -f docker-compose.development.yml build frontend
|
|
docker-compose -f docker-compose.development.yml restart frontend
|
|
elif [[ "$dir" == *"backend"* ]]; then
|
|
docker-compose -f docker-compose.development.yml build backend
|
|
docker-compose -f docker-compose.development.yml restart backend
|
|
fi
|
|
done
|
|
```
|
|
|
|
### **2. Development-Database Reset:**
|
|
```bash
|
|
# Datenbank zurücksetzen
|
|
docker-compose -f docker-compose.development.yml down -v
|
|
docker-compose -f docker-compose.development.yml up -d
|
|
```
|
|
|
|
### **3. Resource-Limits für Development:**
|
|
```yaml
|
|
# In docker-compose.development.yml
|
|
services:
|
|
backend:
|
|
deploy:
|
|
resources:
|
|
limits:
|
|
memory: 512M
|
|
reservations:
|
|
memory: 256M
|
|
```
|
|
|
|
## 🎯 Zusammenfassung
|
|
|
|
### **Vorteile dieses Setups:**
|
|
- ✅ **Linux-Kompatibilität** testen vor Production
|
|
- ✅ **Isolierte Development-DB** (keine Konflikte)
|
|
- ✅ **Flexible Zugriffsmethoden** (direkt/SSH-Tunnel)
|
|
- ✅ **Hot Reload** für schnelle Entwicklung
|
|
- ✅ **Production-ähnliche Umgebung**
|
|
|
|
### **Workflow-Empfehlung:**
|
|
1. **Lokal entwickeln** (Mac mit VS Code)
|
|
2. **Code synchronisieren** (Git/rsync/Remote-SSH)
|
|
3. **Auf Linux testen** (Docker Development)
|
|
4. **Registry deployen** (Staging/Production)
|
|
|
|
**🚀 Perfect für professionelle Cross-Platform-Entwicklung!** |