Some checks failed
Deploy Application / deploy (push) Has been cancelled
227 lines
5.4 KiB
Markdown
227 lines
5.4 KiB
Markdown
# Server-Verzeichnisstruktur
|
|
|
|
## Übersicht
|
|
|
|
Auf dem Production-Server (`deploy@michaelschiemer`) existieren zwei Hauptverzeichnisse im Home-Verzeichnis:
|
|
|
|
```
|
|
/home/deploy/
|
|
├── deployment/ # Infrastructure-as-Code (24M)
|
|
└── michaelschiemer/ # Application Code (491M)
|
|
```
|
|
|
|
## Verzeichnis-Details
|
|
|
|
### `/home/deploy/deployment/` - Infrastructure Repository
|
|
|
|
**Zweck**: Enthält alle Deployment-Infrastruktur-Konfigurationen
|
|
|
|
**Inhalt**:
|
|
```
|
|
deployment/
|
|
├── stacks/ # Docker Compose Stacks
|
|
│ ├── traefik/ # Reverse Proxy & SSL
|
|
│ ├── gitea/ # Git Repository Server
|
|
│ ├── postgresql-production/
|
|
│ ├── postgresql-staging/
|
|
│ ├── production/ # Production Application Stack
|
|
│ ├── staging/ # Staging Application Stack
|
|
│ └── ...
|
|
└── backups/ # Backup-Dateien
|
|
```
|
|
|
|
**Verwendet von**:
|
|
- Ansible Playbooks für Infrastructure-Deployment
|
|
- Docker Compose für Container-Orchestrierung
|
|
- Traefik für Service Discovery
|
|
|
|
**Ansible Variable**:
|
|
```yaml
|
|
stacks_base_path: "/home/deploy/deployment/stacks"
|
|
```
|
|
|
|
**Verwendung in Playbooks**:
|
|
- `setup-infrastructure.yml` - Deployt alle Docker Stacks
|
|
- `backup.yml` - Erstellt Backups
|
|
- `sync-stacks.yml` - Synchronisiert Stack-Konfigurationen
|
|
|
|
---
|
|
|
|
### `/home/deploy/michaelschiemer/` - Application Repository
|
|
|
|
**Zweck**: Enthält den eigentlichen Application-Code (PHP, Composer, etc.)
|
|
|
|
**Inhalt**:
|
|
```
|
|
michaelschiemer/
|
|
├── current/ # Symlink → Aktuelle deployed Version
|
|
│ ├── src/ # PHP Source Code
|
|
│ ├── vendor/ # Composer Dependencies
|
|
│ ├── composer.json
|
|
│ ├── worker.php
|
|
│ └── console.php
|
|
├── .archive/ # Alte Versionen (Rollback)
|
|
├── backups/ # Application-spezifische Backups
|
|
└── ...
|
|
```
|
|
|
|
**Verwendet von**:
|
|
- Ansible Playbooks für Application-Deployment
|
|
- Docker Container (gemountet als Volume)
|
|
- PHP-FPM, Queue Workers, etc.
|
|
|
|
**Ansible Variable**:
|
|
```yaml
|
|
application_code_dest: "/home/deploy/michaelschiemer/current"
|
|
```
|
|
|
|
**Verwendung in Playbooks**:
|
|
- `deploy-application-code.yml` - Deployt neuen Application Code
|
|
- `sync-application-code.yml` - Synchronisiert Code
|
|
- `install-composer-dependencies.yml` - Installiert Dependencies
|
|
|
|
---
|
|
|
|
## Warum zwei Verzeichnisse?
|
|
|
|
### Trennung von Concerns
|
|
|
|
1. **Infrastructure** (`deployment/`)
|
|
- Ändert sich selten
|
|
- Wird von DevOps verwaltet
|
|
- Enthält Docker, Traefik, Datenbanken, etc.
|
|
|
|
2. **Application** (`michaelschiemer/`)
|
|
- Ändert sich häufig (bei jedem Deployment)
|
|
- Wird von Entwicklern verwaltet
|
|
- Enthält Business-Logic, PHP-Code, etc.
|
|
|
|
### Vorteile
|
|
|
|
- **Klarere Verantwortlichkeiten**: Infrastructure vs. Application
|
|
- **Einfacheres Backup**: Separate Backups für Infrastructure und Code
|
|
- **Bessere Skalierung**: Infrastructure kann unabhängig vom Code aktualisiert werden
|
|
- **Rollback-Möglichkeiten**: Alte Application-Versionen in `.archive/`
|
|
|
|
---
|
|
|
|
## Deployment-Workflow
|
|
|
|
### Infrastructure Deployment
|
|
|
|
```bash
|
|
# Infrastructure wird aus lokalem Repository deployed
|
|
ansible-playbook -i inventory/production.yml \
|
|
playbooks/setup-infrastructure.yml \
|
|
--vault-password-file secrets/.vault_pass
|
|
```
|
|
|
|
**Was passiert**:
|
|
1. Ansible kopiert `deployment/stacks/` auf den Server
|
|
2. Docker Compose startet Container basierend auf Stack-Konfigurationen
|
|
3. Traefik entdeckt Services via Docker Labels
|
|
|
|
### Application Deployment
|
|
|
|
```bash
|
|
# Application Code wird aus Gitea deployed
|
|
ansible-playbook -i inventory/production.yml \
|
|
playbooks/deploy-application-code.yml \
|
|
--vault-password-file secrets/.vault_pass
|
|
```
|
|
|
|
**Was passiert**:
|
|
1. Ansible klont/pullt Code aus Gitea
|
|
2. Code wird nach `~/michaelschiemer/current/` deployed
|
|
3. Composer installiert Dependencies
|
|
4. Docker Container werden neu gestartet (mit neuem Code)
|
|
|
|
---
|
|
|
|
## Verzeichnis-Größen
|
|
|
|
```bash
|
|
# Aktuelle Größen (Stand: 2025-11-08)
|
|
24M /home/deploy/deployment # Infrastructure
|
|
491M /home/deploy/michaelschiemer # Application Code
|
|
```
|
|
|
|
**Hinweis**: Die Application ist größer, da sie Composer Dependencies (`vendor/`) enthält.
|
|
|
|
---
|
|
|
|
## Wartung
|
|
|
|
### Prüfen, ob beide Verzeichnisse existieren
|
|
|
|
```bash
|
|
ssh deploy@michaelschiemer.de
|
|
ls -la ~/deployment ~/michaelschiemer
|
|
```
|
|
|
|
### Prüfen, ob `current/` Symlink existiert
|
|
|
|
```bash
|
|
ls -la ~/michaelschiemer/current
|
|
# Sollte zeigen: current -> /path/to/version
|
|
```
|
|
|
|
### Verzeichnis-Größen prüfen
|
|
|
|
```bash
|
|
du -sh ~/deployment ~/michaelschiemer
|
|
```
|
|
|
|
---
|
|
|
|
## Troubleshooting
|
|
|
|
### Problem: `current/` Symlink fehlt
|
|
|
|
**Lösung**:
|
|
```bash
|
|
# Manuell erstellen oder Playbook ausführen
|
|
ansible-playbook -i inventory/production.yml \
|
|
playbooks/deploy-application-code.yml
|
|
```
|
|
|
|
### Problem: Verzeichnis zu groß
|
|
|
|
**Lösung**:
|
|
```bash
|
|
# Alte Versionen aufräumen
|
|
rm -rf ~/michaelschiemer/.archive/*
|
|
# Composer Cache leeren
|
|
rm -rf ~/michaelschiemer/cache/*
|
|
```
|
|
|
|
### Problem: Beide Verzeichnisse fehlen
|
|
|
|
**Lösung**:
|
|
```bash
|
|
# Infrastructure deployen
|
|
ansible-playbook -i inventory/production.yml \
|
|
playbooks/setup-infrastructure.yml
|
|
|
|
# Application deployen
|
|
ansible-playbook -i inventory/production.yml \
|
|
playbooks/deploy-application-code.yml
|
|
```
|
|
|
|
---
|
|
|
|
## Siehe auch
|
|
|
|
- [Deployment README](../README.md) - Übersicht über Deployment-Prozess
|
|
- [Ansible Playbooks](../ansible/playbooks/README.md) - Liste aller Playbooks
|
|
- [Backup Guide](guides/backup-and-rollback-guide.md) - Backup-Strategie
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|