chore: Update Dockerfiles, Makefile and documentation

- Updated Dockerfile.production
- Updated Makefile
- Updated deployment documentation
- Updated docker/ci/Dockerfile, docker/php/Dockerfile, docker/worker/Dockerfile
- Updated dependency scanning documentation
- Added git-hooks documentation
This commit is contained in:
2025-11-01 21:16:03 +01:00
parent e68d1917b0
commit a52142f304
8 changed files with 193 additions and 11 deletions

View File

@@ -0,0 +1,151 @@
# Git Hooks
Dieses Projekt verwendet Git Hooks, um Code-Quality und Commit-Standards automatisch zu ?berpr?fen.
## Aktivierte Hooks
### Pre-commit Hook
**Zweck**: Schnelle Checks vor jedem Commit
**Pr?ft**:
- ? PHP Code Style (PHP-CS-Fixer) f?r ge?nderte PHP-Dateien
- ? JavaScript/TypeScript Linting (ESLint) f?r ge?nderte JS/TS-Dateien
- ? Merge-Konflikt-Marker in staged Dateien
**?berspringen**: `git commit --no-verify`
**Beispiel-Fehler**:
```
? Code style issues found in src/MyClass.php
?? Run: make cs-fix
```
### Commit-msg Hook
**Zweck**: Validierung der Commit-Message nach Conventional Commits
**Format**: `type(scope): subject`
**Erlaubte Types**:
- `feat`: Neue Features
- `fix`: Bugfixes
- `docs`: Dokumentation
- `style`: Code-Formatierung (ohne Funktions?nderung)
- `refactor`: Code-Refactoring
- `perf`: Performance-Verbesserungen
- `test`: Tests hinzuf?gen/?ndern
- `build`: Build-System/Abh?ngigkeiten
- `ci`: CI/CD Konfiguration
- `chore`: Sonstige ?nderungen
- `revert`: Revert eines Commits
**Beispiele**:
```bash
feat: Add user authentication
fix(api): Resolve 502 error in staging
docs: Update README
refactor(framework): Improve DI container
```
**?berspringen**: `git commit --no-verify`
### Pre-push Hook
**Zweck**: Langsamere Checks vor dem Push
**Pr?ft**:
- ? PHPStan Static Analysis
- ? Unit Tests (schneller Teil der Test-Suite)
**Hinweis**: Dieser Hook kann etwas l?nger dauern. Er fragt bei Fehlern, ob trotzdem gepusht werden soll.
**?berspringen**: `git push --no-verify`
## Hook deaktivieren
### Einzelnen Commit ?berspringen
```bash
git commit --no-verify
```
### Einzelnen Push ?berspringen
```bash
git push --no-verify
```
### Hooks komplett deaktivieren
```bash
# Tempor?r alle Hooks deaktivieren
git config core.hooksPath /dev/null
# Wieder aktivieren
git config --unset core.hooksPath
```
## Hook manuell testen
```bash
# Pre-commit Hook testen
.git/hooks/pre-commit
# Commit-msg Hook testen
echo "test: Test message" | .git/hooks/commit-msg /dev/stdin
# Pre-push Hook testen
.git/hooks/pre-push
```
## Hook anpassen
Die Hook-Dateien befinden sich in `.git/hooks/`:
- `.git/hooks/pre-commit` - Pre-commit Checks
- `.git/hooks/commit-msg` - Commit-Message Validierung
- `.git/hooks/pre-push` - Pre-push Checks
**Wichtig**: Hook-Dateien werden nicht ins Repository committed (sie sind in `.git/hooks/`, nicht im Working Directory).
Um Hooks f?r das gesamte Team zu teilen, gibt es mehrere M?glichkeiten:
1. **Husky** (npm package) - f?r Node.js-Projekte
2. **CaptainHook** (PHP package) - f?r PHP-Projekte
3. Manuelles Setup-Skript
## Best Practices
1. **Pre-commit**: Schnelle Checks (< 5 Sekunden)
- Code Style
- Syntax-Checks
- Merge-Konflikt-Detection
2. **Pre-push**: Langsamere Checks (< 2 Minuten)
- Static Analysis
- Unit Tests
- Integration Tests (optional)
3. **CI/CD**: Umfassende Checks
- Alle Tests
- Coverage Reports
- Security Scans
## Troubleshooting
### Hook wird nicht ausgef?hrt
```bash
# Pr?fe Berechtigungen
ls -la .git/hooks/
# Mache Hook ausf?hrbar
chmod +x .git/hooks/pre-commit
```
### Hook ist zu langsam
- Verringere die Anzahl der Checks im pre-commit Hook
- Verschiebe langsamere Checks in den pre-push Hook
- Nutze `--no-verify` f?r schnelle WIP-Commits
### Hook schl?gt im Docker fehl
Die Hooks pr?fen automatisch, ob sie in Docker laufen und passen die Befehle entsprechend an.
## Weitere Hooks hinzuf?gen
Weitere n?tzliche Hooks:
- `post-merge`: Automatische `composer install` nach `git pull`
- `post-checkout`: Automatische Dependency-Updates
- `prepare-commit-msg`: Automatische Ticket-Nummern in Commit-Messages