diff --git a/AGENTS.md b/AGENTS.md index e76b757..61a562a 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -13,6 +13,7 @@ # Ferienwohnung Stommer - Special offers are evaluated automatically by `PriceCalculator`; discounts are `QuoteLineType::Discount` lines with negative amounts. - Portal sync lives in `app/Channels` (connector interface + registry in `config/channels.php`, iCal connector/parser/feed). Our system leads; `SyncChannel` imports portal occupations as `BlockedPeriod` rows with `channel_id`; each channel's export feed excludes its own blocks. Observers on Booking/BlockedPeriod create `ChannelTask`s for portals with `requires_manual_blocking`. Portal booking e-mails are a fast path (`app/Channels/Mail`, `ProcessPortalMail`): they create blocks with source `email`, which `SyncChannel` later confirms/replaces and never removes as stale. Portal analysis: `docs/PORTALE.md`. - Website = theme system (`docs/THEMES.md`): themes live in `resources/themes/` (theme.json, theme.css, theme.js, views); views resolve via the `theme::` namespace (theme → parent → base `ostsee-licht`). Pages are lists of sections (`app/Themes/Sections`, catalogue in `config/themes.php`); seasonal `Appearance`s override tokens/texts/hero photo. Theme views use only token colour classes (`bg-accent`, `text-muted`, …). Resolve `Theme` lazily (`app(Theme::class)`), never in constructors – middleware `ResolveTheme` replaces it per request. +- Deployment: `scripts/deploy.sh setup|deploy|rollback|releases|artisan` (atomic releases on Strato, docs/DEPLOYMENT.md); CI `.gitea/workflows/deploy.yml`. Production has no dev packages (no factories/Faker) – production seeding via `ProductionSeeder`. - Vite fonts plugin is removed on purpose (corporate proxy breaks remote font downloads, and fonts must be self-hosted for GDPR). - PHP/Composer on this machine: winget package dir `%LOCALAPPDATA%\Microsoft\WinGet\Packages\PHP.PHP.8.4_*` (Composer as `composer\composer.phar` there). - Git remote: Gitea `https://gitea.stommer.de/Lars/fewo-stommer.git`, branch `main`. diff --git a/CLAUDE.md b/CLAUDE.md index e76b757..61a562a 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -13,6 +13,7 @@ # Ferienwohnung Stommer - Special offers are evaluated automatically by `PriceCalculator`; discounts are `QuoteLineType::Discount` lines with negative amounts. - Portal sync lives in `app/Channels` (connector interface + registry in `config/channels.php`, iCal connector/parser/feed). Our system leads; `SyncChannel` imports portal occupations as `BlockedPeriod` rows with `channel_id`; each channel's export feed excludes its own blocks. Observers on Booking/BlockedPeriod create `ChannelTask`s for portals with `requires_manual_blocking`. Portal booking e-mails are a fast path (`app/Channels/Mail`, `ProcessPortalMail`): they create blocks with source `email`, which `SyncChannel` later confirms/replaces and never removes as stale. Portal analysis: `docs/PORTALE.md`. - Website = theme system (`docs/THEMES.md`): themes live in `resources/themes/` (theme.json, theme.css, theme.js, views); views resolve via the `theme::` namespace (theme → parent → base `ostsee-licht`). Pages are lists of sections (`app/Themes/Sections`, catalogue in `config/themes.php`); seasonal `Appearance`s override tokens/texts/hero photo. Theme views use only token colour classes (`bg-accent`, `text-muted`, …). Resolve `Theme` lazily (`app(Theme::class)`), never in constructors – middleware `ResolveTheme` replaces it per request. +- Deployment: `scripts/deploy.sh setup|deploy|rollback|releases|artisan` (atomic releases on Strato, docs/DEPLOYMENT.md); CI `.gitea/workflows/deploy.yml`. Production has no dev packages (no factories/Faker) – production seeding via `ProductionSeeder`. - Vite fonts plugin is removed on purpose (corporate proxy breaks remote font downloads, and fonts must be self-hosted for GDPR). - PHP/Composer on this machine: winget package dir `%LOCALAPPDATA%\Microsoft\WinGet\Packages\PHP.PHP.8.4_*` (Composer as `composer\composer.phar` there). - Git remote: Gitea `https://gitea.stommer.de/Lars/fewo-stommer.git`, branch `main`. diff --git a/docs/DEPLOYMENT.md b/docs/DEPLOYMENT.md new file mode 100644 index 0000000..8d7b02a --- /dev/null +++ b/docs/DEPLOYMENT.md @@ -0,0 +1,85 @@ +# Deployment auf Strato + +Stand: 22.10.2026 · Skript: `scripts/deploy.sh` · CI: `.gitea/workflows/deploy.yml` + +## 1. Prinzip + +``` +Gitea (main/Tag) ──► Build (CI oder lokal): git-Stand · composer --no-dev · npm run build + │ tar.gz + ▼ SSH +Strato / + releases/20261022…/ ◄─ entpackt + shared/.env ◄─ einmalig von Hand + shared/storage/ ◄─ Uploads, Logs, Sessions (bleiben) + current ──► releases/… ◄─ atomar umgeschaltet nach migrate + optimize + Domain-Zielverzeichnis = /current/public + │ + ▼ https://…/up – Gesundheitscheck, bei Fehler automatischer Rollback +``` + +Auf dem Server werden nur **bash, tar und PHP-CLI** gebraucht – kein Composer, kein Node, kein Git, kein rsync. + +## 2. SSH oder SFTP? + +**Empfehlung: SSH.** Das Skript führt nach dem Hochladen Befehle auf dem Server aus (Archiv entpacken, Datenbank migrieren, Caches erzeugen, Version umschalten, ggf. zurückschalten). Das geht nur mit SSH. + +Nur mit SFTP wäre ein Deployment möglich, aber deutlich schwächer: +- Kein Entpacken auf dem Server → jede Datei einzeln übertragen (über 10.000 Dateien, mehrere Minuten pro Update, unterbrechungsanfällig). +- Migrationen und Caches müssten über einen gesicherten Web-Aufruf angestoßen werden; kein `artisan` für Wartung und Fehlersuche. +- Umschalten wäre per SFTP-Symlink möglich, aber ohne sauberen Rückfall bei Fehlern. + +Strato richtet beide Zugänge im selben Menü ein (Kundenlogin › Datenbanken und Webspace › **SFTP & SSH**). Bei Hosting Pro sollte SSH enthalten sein – bitte dort prüfen. Falls nicht: Bescheid geben, dann ergänze ich einen SFTP-Modus. + +## 3. Einmalige Einrichtung bei Strato + +1. **PHP-Version** auf 8.4 stellen (Datenbanken und Webspace › PHP-Version). +2. **SSH-Zugang** anlegen (SFTP & SSH); Benutzername notieren. Eigenen SSH-Schlüssel hinterlegen oder einmalig `ssh-copy-id @ssh.strato.de`. +3. Per SSH prüfen: + ```bash + ssh @ssh.strato.de + ls /opt | grep RZphp # PHP-CLI-Pfad, z. B. /opt/RZphp84/bin/php-cli + /opt/RZphp84/bin/php-cli -v + ``` +4. **MySQL-Datenbank** anlegen (Datenbanken verwalten); Host, Name, Benutzer, Passwort notieren. +5. Lokal `scripts/deploy.example.env` nach `scripts/deploy.production.env` kopieren und ausfüllen (wird nicht committet). +6. `bash scripts/deploy.sh production setup` – legt die Ordner an und zeigt die PHP-Version. +7. `.env.production.example` ausfüllen (u. a. `APP_KEY` via `php artisan key:generate --show`, Datenbank, SMTP/IMAP-Passwort, Tokens) und auf den Server nach `/shared/.env` kopieren (z. B. per SFTP). +8. Erstes Deployment: `bash scripts/deploy.sh production deploy` +9. Ersteinrichtung der Daten und erster Admin: + ```bash + bash scripts/deploy.sh production artisan db:seed --class=ProductionSeeder --force + bash scripts/deploy.sh production artisan make:filament-user + ``` +10. **Domain-Zielverzeichnis** (Domains › Domain verwalten › Ziel) auf `/current/public` setzen; SSL-Zertifikat aktivieren. +11. **Cronjob** (Kundenlogin › Cronjobs), jede Minute: + ``` + /opt/RZphp84/bin/php-cli //current/artisan schedule:run + ``` + Falls Cronjobs nicht minütlich möglich sind: `FEWO_SCHEDULER_TOKEN` setzen und n8n jede Minute `GET https://…/automation/scheduler?token=…` aufrufen lassen. +12. Überwachung: n8n alle 5 Min. `GET https://…/health/sync?token=` (200 = ok, 503 = Störung). + +**Testbetrieb zuerst:** Für eine Subdomain (z. B. `test.fewo-stommer.de`) eine zweite Konfiguration `scripts/deploy.staging.env` mit eigenem `DEPLOY_PATH`, eigener Datenbank und eigenem `shared/.env` anlegen; `bash scripts/deploy.sh staging deploy`. + +## 4. Tägliche Nutzung + +| Aufgabe | Befehl | +|---|---| +| Neue Version ausliefern | `bash scripts/deploy.sh production deploy` (baut den **letzten Commit**) | +| Zurück zur vorigen Version | `bash scripts/deploy.sh production rollback` (Migrationen bleiben bestehen) | +| Versionen anzeigen | `bash scripts/deploy.sh production releases` | +| Artisan auf dem Server | `bash scripts/deploy.sh production artisan about` | + +Windows: in Git Bash ausführen; `COMPOSER_BIN="php /c/…/composer.phar"` in der `.env`-Datei des Deployments setzen, falls `composer` nicht im PATH ist. + +## 5. Automatisch über Gitea Actions + +- Workflow `.gitea/workflows/deploy.yml`: **Tests bei jedem Push**; **Deployment** bei Tags `v*` (z. B. `git tag v1.0.0 && git push --tags`) oder per Knopfdruck (Actions › Deploy › Run workflow, Ziel production/staging). +- Voraussetzung: Gitea Actions aktiviert und ein **act_runner** registriert – passt gut auf den privaten Server (Docker). Anleitung: Gitea-Doku „Act Runner“. +- Repository-Secrets: `DEPLOY_SSH_KEY` (privater Schlüssel, dessen öffentlicher Teil bei Strato hinterlegt ist), `DEPLOY_HOST`, `DEPLOY_USER`, `DEPLOY_PATH`, `DEPLOY_PHP`, `DEPLOY_URL`. + +## 6. Getestet / offen + +- Lokal im Testmodus (`DEPLOY_HOST=local`) erfolgreich: Build (~19 MB), Upload, Entpacken, alle Migrationen auf frischer Datenbank, `optimize`, Ersteinrichtung per `ProductionSeeder`, alle Seiten und Admin-Login liefern 200. +- **Nicht** unter Windows prüfbar: der Symlink-Wechsel von `current` (Git Bash legt Kopien statt Symlinks an). Unter Linux (Strato) ist das Standardverhalten; der erste Lauf auf dem Testbetrieb bestätigt es – bei Fehler greift der automatische Rollback. +- Bei Strato zu prüfen: SSH im Tarif, PHP-CLI-Pfad, ob das Domain-Ziel einem Symlink (`current`) folgt, minütliche Cronjobs.