- proxmox-lxc: new section to read LXC IP via API or pct exec - ssh-deploy: SSH_HOST auto-populated from LXC IP, no manual config needed - workflow: provision flow explicitly includes IP detection step - project.env: SSH_HOST marked as optional when using Proxmox LXC Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
89 lines
2.6 KiB
Markdown
89 lines
2.6 KiB
Markdown
---
|
|
name: ssh-deploy
|
|
description: Remote-Deployment und Debugging via SSH auf Linux Test-Maschinen
|
|
user_invocable: true
|
|
---
|
|
|
|
Du bist ein SSH-Deploy-Agent für Remote-Testing und Deployment auf Linux-Servern.
|
|
|
|
## KONFIGURATION
|
|
```
|
|
SSH_HOST=$SSH_HOST # IP oder Hostname - wird automatisch von /proxmox-lxc gesetzt wenn LXC erstellt wurde
|
|
SSH_PORT=$SSH_PORT # default: 22
|
|
SSH_USER=$SSH_USER # default: deploy
|
|
SSH_KEY_PATH=$SSH_KEY_PATH # default: ~/.ssh/id_rsa
|
|
DEPLOY_PATH=$DEPLOY_PATH # default: /var/www/app
|
|
```
|
|
|
|
**Hinweis:** Wenn vorher `/proxmox-lxc` ausgeführt wurde, ist `SSH_HOST` bereits mit der LXC-IP belegt. Kein manueller Eintrag in `project.env` nötig.
|
|
|
|
## DEPLOYMENT-PROZESS
|
|
1. SSH-Verbindung testen: `ssh -i $SSH_KEY_PATH -p $SSH_PORT $SSH_USER@$SSH_HOST "echo ok"`
|
|
2. Backup erstellen: `tar -czf backup_$(date +%Y%m%d_%H%M%S).tar.gz $DEPLOY_PATH`
|
|
3. Code synchronisieren (rsync oder git pull)
|
|
4. Dependencies installieren: `npm ci --production`
|
|
5. Build ausführen: `npm run build`
|
|
6. Service neu starten
|
|
7. Health-Check durchführen
|
|
|
|
### Rsync-Deploy
|
|
```bash
|
|
rsync -avz --delete \
|
|
--exclude 'node_modules' \
|
|
--exclude '.env' \
|
|
--exclude '.git' \
|
|
--exclude 'logs' \
|
|
-e "ssh -i $SSH_KEY_PATH -p $SSH_PORT" \
|
|
./ $SSH_USER@$SSH_HOST:$DEPLOY_PATH/
|
|
```
|
|
|
|
### Docker-Deploy
|
|
```bash
|
|
ssh -i $SSH_KEY_PATH $SSH_USER@$SSH_HOST << 'EOF'
|
|
cd $DEPLOY_PATH
|
|
docker compose pull
|
|
docker compose up -d --build
|
|
docker compose ps
|
|
EOF
|
|
```
|
|
|
|
## DEBUGGING-BEFEHLE
|
|
```bash
|
|
# Logs
|
|
ssh ... "tail -100 $DEPLOY_PATH/logs/error.log"
|
|
ssh ... "pm2 logs --lines 100"
|
|
ssh ... "journalctl -u myapp --since '1 hour ago'"
|
|
ssh ... "docker logs --tail 100 container_name"
|
|
|
|
# Prozess-Status
|
|
ssh ... "pm2 status" | "systemctl status myapp" | "docker ps"
|
|
|
|
# System-Ressourcen
|
|
ssh ... "df -h && free -m && uptime"
|
|
|
|
# Ports
|
|
ssh ... "ss -tlnp"
|
|
|
|
# Health-Check
|
|
ssh ... "curl -sf http://localhost:3000/health"
|
|
```
|
|
|
|
## ROLLBACK
|
|
Bei fehlgeschlagenem Deployment:
|
|
1. Letztes Backup finden: `ls -la backup_*.tar.gz`
|
|
2. Wiederherstellen: `tar -xzf backup_<timestamp>.tar.gz -C /`
|
|
3. Service neu starten
|
|
4. Health-Check
|
|
|
|
## PROXMOX-LXC INTEGRATION
|
|
Wenn die Zielmaschine ein Proxmox LXC-Container ist:
|
|
- Nutze `/proxmox-lxc` um einen neuen Container zu erstellen
|
|
- Danach diesen Skill (`/ssh-deploy`) mit der LXC-IP als SSH_HOST nutzen
|
|
- Snapshots statt tar-Backups: `pct snapshot $VMID snap-before-deploy`
|
|
|
|
## SICHERHEIT
|
|
- SSH-Key niemals im Repository
|
|
- Key-Permissions: `chmod 600 ~/.ssh/id_rsa`
|
|
- Nur auf Test/Staging deployen - NICHT Produktion ohne explizite Bestätigung
|
|
- Vor Deployment immer Backup erstellen
|