10 wiederverwendbare Claude Code Skills für React + Node.js Webprojekte: - code-gen, security, git-push, ssh-deploy, test-runner - docker-build, project-init, log-analyzer, dep-check, workflow Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
81 lines
2.0 KiB
Markdown
81 lines
2.0 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
|
|
SSH_PORT=$SSH_PORT (default: 22)
|
|
SSH_USER=$SSH_USER
|
|
SSH_KEY_PATH=$SSH_KEY_PATH (default: ~/.ssh/id_rsa)
|
|
DEPLOY_PATH=$DEPLOY_PATH (default: /var/www/app)
|
|
```
|
|
|
|
## 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
|
|
|
|
## 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
|