Deploy: keep only the active release on Strato (file quota), release history as Git tags in Gitea

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Lars StommerandClaude Opus 5.5 committed 2026-10-22 17:16:32 +02:00
1 parent 669fb45731
commit 7355466231
7 files changed
+58 -25

No files matched your search

+1 -1
View File
@@ -1,7 +1,7 @@
# Tests on every push; deployment to Strato for tags "v*" or by hand (Gitea › Actions › Deploy › Run workflow).
# Needs a Gitea act_runner (e.g. on the private server) and these repository secrets:
# DEPLOY_SSH_KEY private key whose public key is stored at Strato (SFTP & SSH)
# DEPLOY_HOST ssh.strato.de
# DEPLOY_HOST package-specific SSH server, e.g. 51539426.ssh.w1.strato.hosting (not ssh.strato.de)
# DEPLOY_USER SSH user from the Strato customer login
# DEPLOY_PATH e.g. fewo-production
# DEPLOY_PHP e.g. /opt/RZphp84/bin/php-cli
+1 -1
View File
@@ -14,7 +14,7 @@ # Ferienwohnung Stommer
- 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/<key>` (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.
- Operations (environments, Strato access, server .env, admin accounts, 2FA, known pitfalls): `docs/BETRIEB.md` – read it before touching a server. Admin accounts: `php artisan users:create`; 2FA (Filament app authentication) is mandatory for admins via `RequireTwoFactorForAdmins`.
- Deployment: `scripts/deploy.sh <env> 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`.
- Deployment: `scripts/deploy.sh <env> setup|deploy [ref]|rollback|releases|artisan` (atomic releases on Strato, docs/DEPLOYMENT.md; the server keeps only the active release because of Strato's file quota – history = Git tags `deploy/<env>/<timestamp>`); 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`.
+1 -1
View File
@@ -14,7 +14,7 @@ # Ferienwohnung Stommer
- 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/<key>` (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.
- Operations (environments, Strato access, server .env, admin accounts, 2FA, known pitfalls): `docs/BETRIEB.md` – read it before touching a server. Admin accounts: `php artisan users:create`; 2FA (Filament app authentication) is mandatory for admins via `RequireTwoFactorForAdmins`.
- Deployment: `scripts/deploy.sh <env> 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`.
- Deployment: `scripts/deploy.sh <env> setup|deploy [ref]|rollback|releases|artisan` (atomic releases on Strato, docs/DEPLOYMENT.md; the server keeps only the active release because of Strato's file quota – history = Git tags `deploy/<env>/<timestamp>`); 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`.
+3 -3
View File
@@ -118,15 +118,15 @@ ## 8. Bekannte Eigenheiten und Lösungen
| Domain-Ziel `current/public` nicht wählbar | Strato erlaubt kein Symlink-Ziel | Domain auf den Deploy-Ordner, `.htaccess` leitet weiter |
| Ersteinrichtung mit Factories schlägt fehl | Produktion ohne Dev-Pakete | `ProductionSeeder` |
| Kein SSL für Subdomain | Paket erlaubt SSL nur für Hauptdomains | Testbetrieb auf `stommer.info` |
| `Disk quota exceeded` beim Hochladen | Webspace-Kontingent voll (geteilt mit allen anderen Seiten/Backups im Paket); jede Version belegt ~136 MB | Staging behält nur 2 Versionen (`DEPLOY_KEEP=2`); halbe Versionen/`upload-*.tgz` eines abgebrochenen Laufs im Deploy-Ordner löschen. **Ordner außerhalb des Deploy-Ordners entscheidet nur Lars** (teils produktiv). |
| `Disk quota exceeded` beim Hochladen / Hinweis „zu viele Dateien“ | Webspace-Kontingent voll (geteilt mit allen anderen Seiten/Backups im Paket); jede Version belegt ~136 MB | Es ist die **Anzahl der Dateien** (Inode-Limit), nicht der Platz. Der Server behält nur die aktive Version (Geschichte als Git-Tags in Gitea), `vendor` wird beim Build ausgedünnt (~15.000 statt ~19.500 Dateien je Version); Reste abgebrochener Läufe räumt das nächste Deployment selbst weg. **Ordner außerhalb des Deploy-Ordners entscheidet nur Lars** (teils produktiv). |
| Windows: Symlinks, `php` nicht im PATH | Git Bash | Deploy nur gegen Strato testen; `export PATH="<php-ordner>:$PATH"` |
## 9. Nützliche Befehle
```bash
bash scripts/deploy.sh staging deploy # ausliefern (letzter Commit)
bash scripts/deploy.sh staging rollback # vorige Version
bash scripts/deploy.sh staging releases # Versionen auf dem Server
bash scripts/deploy.sh staging releases # aktive Version + Deploy-Tags in Git
bash scripts/deploy.sh staging deploy deploy/staging/<zeitstempel> # frühere Version erneut ausliefern
bash scripts/deploy.sh staging artisan about # Zustand der Installation
bash scripts/deploy.sh staging artisan migrate:status
ssh -i ~/.ssh/strato_fewo stu100093250@51539426.ssh.w1.strato.hosting \
+5 -2
View File
@@ -66,8 +66,11 @@ ## 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` |
| Bestimmten Stand ausliefern | `bash scripts/deploy.sh production deploy <commit oder tag>` |
| Zurück zu einer früheren Version | `bash scripts/deploy.sh production releases` zeigt die Deploy-Tags; dann `bash scripts/deploy.sh production deploy deploy/production/<zeitstempel>` (Migrationen werden nicht zurückgenommen) |
| Sofort zurück, solange die alte Version noch auf dem Server liegt (nur während eines laufenden Deployments) | `bash scripts/deploy.sh production rollback` |
**Versionsgeschichte in Gitea statt auf Strato:** Strato begrenzt die Anzahl der Dateien im Paket (eine Version ≈ 15.000 Dateien). Auf dem Server liegt deshalb nur die **aktive** Version, während eines Deployments kurz zusätzlich die neue. Die alte wird erst gelöscht, wenn die neue den Gesundheitscheck bestanden hat – schlägt er fehl, wird automatisch zurückgeschaltet. Jede erfolgreiche Auslieferung wird als Tag `deploy/<umgebung>/<zeitstempel>` in Gitea festgehalten; ein Build ist durch `composer.lock`/`package-lock.json` reproduzierbar. Außerdem entfernt der Build Sprachdateien außer de/en sowie Tests/Doku aus `vendor` (~4.800 Dateien weniger).
| 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.
+3 -2
View File
@@ -16,8 +16,9 @@ DEPLOY_PHP=/opt/RZphp84/bin/php-cli
# Public address for the health check after switching (empty = no check, no automatic rollback)
DEPLOY_URL=https://www.fewo-stommer.de
# Number of releases kept on the server for rollbacks
DEPLOY_KEEP=5
# After a successful deployment, tag the commit as deploy/<environment>/<timestamp> and push the tag to Gitea
# (the server keeps only the active release; going back = deploy an older tag). 0 = no tags.
DEPLOY_TAG=1
# Local build: how Composer is called (Windows example: "php /c/path/to/composer.phar")
# COMPOSER_BIN=composer
+44 -15
View File
@@ -3,15 +3,18 @@
# Deployment to Strato (or any SSH host offering bash, tar and a PHP CLI) with atomic releases.
#
# scripts/deploy.sh <environment> setup create the folder structure on the server (once)
# scripts/deploy.sh <environment> deploy build, upload, migrate, switch, health check (rollback on failure)
# scripts/deploy.sh <environment> rollback switch back to the previous release
# scripts/deploy.sh <environment> releases list releases on the server
# scripts/deploy.sh <environment> deploy [ref] build a Git commit/tag (default HEAD), upload, migrate, switch,
# health check (switch back on failure), tag it in Gitea
# scripts/deploy.sh <environment> rollback switch back while the previous release is still on the server
# scripts/deploy.sh <environment> releases active release on the server and deployment tags in Git
# scripts/deploy.sh <environment> artisan <args> run an artisan command in the active release
#
# Settings come from scripts/deploy.<environment>.env (not committed, see scripts/deploy.example.env)
# or from environment variables (CI). Server layout below DEPLOY_PATH:
#
# releases/<timestamp>/ one folder per release (code, vendor, built assets)
# releases/<timestamp>/ the active release (code, vendor, built assets); during a deployment also the new one.
# Older releases are not kept (Strato file quota) – history lives in Git as tags
# deploy/<environment>/<timestamp>; going back = deploy that tag again.
# shared/.env production settings – created by hand once
# shared/storage/ uploads, logs, sessions, cache – survive every release
# current -> releases/… active release (CLI, cron); the domain points at DEPLOY_PATH, whose .htaccess
@@ -35,7 +38,7 @@ fi
DEPLOY_USER="${DEPLOY_USER:-}"
DEPLOY_PORT="${DEPLOY_PORT:-22}"
DEPLOY_PHP="${DEPLOY_PHP:-/opt/RZphp84/bin/php-cli}"
DEPLOY_KEEP="${DEPLOY_KEEP:-5}"
DEPLOY_TAG="${DEPLOY_TAG:-1}"
DEPLOY_URL="${DEPLOY_URL:-}"
DEPLOY_SSH_KEY="${DEPLOY_SSH_KEY:-}"
DEPLOY_SSH_KEY="${DEPLOY_SSH_KEY/#\~/$HOME}"
@@ -95,11 +98,19 @@ case "$cmd" in
receive)
release="$1"
mkdir -p "releases/$release"
tar -xzf "upload-$release.tgz" -C "releases/$release"
tar -xzf "upload-$release.tgz" -C "releases/$release" || { rm -rf "releases/$release" "upload-$release.tgz"; exit 1; }
rm -f "upload-$release.tgz"
;;
cleanup)
# Everything except the active release: older releases, leftovers of aborted uploads.
active="$(basename "$(readlink current 2>/dev/null || echo none)")"
for dir in releases/*; do
[[ -d "$dir" && "$(basename "$dir")" != "$active" ]] && rm -rf "$dir" && echo "Entfernt: $dir"
done
rm -f upload-*.tgz
;;
activate)
release="$1"; keep="$2"; dir="releases/$release"
release="$1"; dir="releases/$release"
[[ -f shared/.env ]] || { echo "shared/.env fehlt – erst anlegen (siehe docs/DEPLOYMENT.md)." >&2; exit 1; }
rm -rf "$dir/storage"
ln -s ../../shared/storage "$dir/storage"
@@ -114,7 +125,6 @@ case "$cmd" in
)
readlink current > .previous_release 2>/dev/null || true
switch_to "$dir"
ls -1d releases/* | sort | head -n -"$keep" | xargs -r rm -rf
echo "Aktiv: $release"
;;
rollback)
@@ -123,13 +133,13 @@ case "$cmd" in
if [[ -z "$target" || "$target" == "$active" || ! -d "$target" ]]; then
target="$(ls -1d releases/* | sort | grep -vx "$active" | tail -n 1 || true)"
fi
[[ -n "$target" && -d "$target" ]] || { echo "Keine frühere Version vorhanden." >&2; exit 1; }
[[ -n "$target" && -d "$target" ]] || { echo "Keine frühere Version mehr auf dem Server – stattdessen einen Deploy-Tag erneut ausliefern (siehe: releases)." >&2; exit 1; }
switch_to "$target"
echo "$active" > .previous_release
echo "Zurückgeschaltet auf: $target (Datenbank-Migrationen werden dabei nicht zurückgenommen)"
;;
releases)
ls -1 releases
echo "Auf dem Server: $(ls -1 releases | tr '\n' ' ')"
echo "Aktiv: $(readlink current 2>/dev/null || echo '–')"
;;
artisan)
@@ -184,13 +194,14 @@ prune_vendor() {
}
build() {
say "Baue Version aus Git-Stand $(git -C "$ROOT" rev-parse --short HEAD)"
if [[ -n "$(git -C "$ROOT" status --porcelain)" ]]; then
REVISION="$(git -C "$ROOT" rev-parse --verify "$REF^{commit}")" || fail "Unbekannter Git-Stand: $REF"
say "Baue Version aus Git-Stand $REF (${REVISION:0:7})"
if [[ "$REF" == "HEAD" && -n "$(git -C "$ROOT" status --porcelain)" ]]; then
echo "Hinweis: Nicht committete Änderungen werden NICHT ausgeliefert (gebaut wird der letzte Commit)."
fi
BUILD_DIR="$(mktemp -d)"
git -C "$ROOT" archive --format=tar HEAD | tar -x -C "$BUILD_DIR"
git -C "$ROOT" archive --format=tar "$REVISION" | tar -x -C "$BUILD_DIR"
(
cd "$BUILD_DIR"
$COMPOSER_BIN install --no-dev --prefer-dist --optimize-autoloader --no-interaction --no-progress
@@ -198,13 +209,22 @@ build() {
npm run build
rm -rf node_modules tests docs .gitea .github scripts storage .env.example .env.production.example .ai .claude .cursor AGENTS.md CLAUDE.md boost.json phpunit.xml
prune_vendor
git -C "$ROOT" rev-parse HEAD > REVISION
echo "$REVISION" > REVISION
)
ARCHIVE="$BUILD_DIR.tgz"
tar -czf "$ARCHIVE" -C "$BUILD_DIR" .
echo "Paket: $(du -h "$ARCHIVE" | cut -f1)"
}
# Records the live version in Git (and Gitea) – the release history, since the server keeps no old releases.
tag_release() {
[[ "$DEPLOY_TAG" == "1" ]] || return 0
local tag="deploy/$ENVIRONMENT/$1"
git -C "$ROOT" -c user.name="${GIT_AUTHOR_NAME:-deploy}" -c user.email="${GIT_AUTHOR_EMAIL:-deploy@localhost}" tag -a "$tag" -m "Deployed to $ENVIRONMENT" "$REVISION" || { echo "Hinweis: Git-Tag $tag konnte nicht angelegt werden."; return 0; }
git -C "$ROOT" push -q origin "$tag" 2>/dev/null || git -C "$ROOT" push -q origin "$tag" || echo "Hinweis: Tag $tag nur lokal angelegt – bitte später 'git push origin $tag'."
echo "Git-Tag: $tag"
}
health_check() {
[[ -n "$DEPLOY_URL" ]] || { echo "Kein DEPLOY_URL gesetzt – Gesundheitscheck übersprungen."; return 0; }
# First deployment: the domain does not point to current/public yet.
@@ -226,18 +246,24 @@ case "$COMMAND" in
remote setup
;;
deploy)
REF="${1:-HEAD}"
build
RELEASE="$(date -u +%Y%m%d%H%M%S)"
say "Räume Server auf (nur die aktive Version bleibt)"
remote cleanup
say "Übertrage Version $RELEASE"
upload "$ARCHIVE" "$RELEASE"
remote receive "$RELEASE"
say "Migrieren, Caches aufwärmen, umschalten"
remote activate "$RELEASE" "$DEPLOY_KEEP"
remote activate "$RELEASE"
if ! health_check; then
say "Gesundheitscheck fehlgeschlagen – schalte zurück"
remote rollback
remote cleanup
fail "Deployment zurückgerollt. Logs: scripts/deploy.sh $ENVIRONMENT artisan about / shared/storage/logs"
fi
remote cleanup
tag_release "$RELEASE"
rm -rf "$BUILD_DIR" "$ARCHIVE"
say "Fertig: Version $RELEASE ist live."
;;
@@ -247,6 +273,9 @@ case "$COMMAND" in
;;
releases)
remote releases
echo "Deploy-Tags in Git (neueste zuerst; zurück mit: scripts/deploy.sh $ENVIRONMENT deploy <tag>):"
git -C "$ROOT" fetch -q --tags origin 2>/dev/null || true
git -C "$ROOT" tag -l "deploy/$ENVIRONMENT/*" --sort=-refname | head -n 10
;;
artisan)
remote artisan "$@"