From 350b0db7ee2dd7c2d79252de311080708f5ce44a Mon Sep 17 00:00:00 2001 From: mhoennig Date: Wed, 22 Jul 2026 07:15:32 +0200 Subject: [PATCH] scripts/deploy-prod: Ziel aus Wurzel-.env statt scripts/deploy.env DEPLOY_TARGET wird jetzt aus der .env im Repo-Wurzelordner gelesen (die von der bestehenden .gitignore-Regel ohnehin ignoriert wird; Vite liest sie nicht, da dessen Env unter frontend/ liegt). scripts/deploy.env(.example) entfaellt; neue Vorlage .env.example im Wurzelordner. Argument hat weiterhin Vorrang, ~ bleibt fuer die Remote-Seite erhalten (kein source). .gitignore: eigene scripts/deploy.env-Zeile zurueckgenommen, Kommentar an der .env-Regel ergaenzt. README (de/en) entsprechend aktualisiert. Lokal verifiziert: Fallback liest aus Wurzel-.env, .env ignoriert, .env.example getrackt. Co-Authored-By: Claude Opus 4.8 --- .env.example | 11 +++++++++++ .gitignore | 3 +-- README.de.md | 4 ++-- README.md | 4 ++-- scripts/deploy-prod.sh | 12 ++++++------ scripts/deploy.env.example | 11 ----------- 6 files changed, 22 insertions(+), 23 deletions(-) create mode 100644 .env.example delete mode 100644 scripts/deploy.env.example diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..0a2fd5d --- /dev/null +++ b/.env.example @@ -0,0 +1,11 @@ +# Vorlage für .env — kopieren und anpassen: +# cp .env.example .env +# +# .env liegt im Repo-Wurzelordner, ist git-ignoriert (enthält deinen Server/Pfad) +# und wird von scripts/deploy-prod.sh benutzt, wenn KEIN Ziel als Argument +# übergeben wird. Ein Argument hat immer Vorrang. +# +# Wert = rsync-Ziel (user@host:pfad). Das `~` wird auf der Remote-Seite +# aufgelöst; Anführungszeichen sind optional. Keine Kommentare hinter dem Wert. + +DEPLOY_TARGET=mih00@mih00.hostsharing.net:~/doms/werkbaum.javagil.de/htdocs-ssl diff --git a/.gitignore b/.gitignore index 42afcc7..35a5bd6 100644 --- a/.gitignore +++ b/.gitignore @@ -57,11 +57,10 @@ frontend/node_modules/ frontend/dist/ # === Geheimnisse / lokale Umgebung === +# .env hält u. a. DEPLOY_TARGET für scripts/deploy-prod.sh (Vorlage: .env.example) .env .env.local *.local -# Deploy-Ziel (scripts/deploy-prod.sh) — lokal halten; Vorlage .example bleibt drin -scripts/deploy.env # === Temporäres === tmp/ diff --git a/README.de.md b/README.de.md index 99e5ba7..6f9613e 100644 --- a/README.de.md +++ b/README.de.md @@ -96,8 +96,8 @@ scripts/deploy-prod.sh mih00@mih00.hostsharing.net:~/doms/werkbaum.javagil.de/ht ``` Das Ziel ist entweder dieses Argument oder — ohne Argument — die Variable -`DEPLOY_TARGET` aus der **git-ignorierten** Datei `scripts/deploy.env` (Vorlage: -`scripts/deploy.env.example`, einmal kopieren und den Pfad eintragen). Ein +`DEPLOY_TARGET` aus der **git-ignorierten** Datei `.env` (Vorlage: +`.env.example`, einmal kopieren und den Pfad eintragen). Ein Argument hat Vorrang. Ohne `-y` zeigt es zuerst eine `--dry-run`-Vorschau und fragt nach. `rsync diff --git a/README.md b/README.md index a4df241..1fb19a2 100644 --- a/README.md +++ b/README.md @@ -94,8 +94,8 @@ scripts/deploy-prod.sh mih00@mih00.hostsharing.net:~/doms/werkbaum.javagil.de/ht ``` The target is either this argument or — with no argument — the `DEPLOY_TARGET` -variable from the **git-ignored** file `scripts/deploy.env` (template: -`scripts/deploy.env.example`, copy it once and fill in the path). An argument +variable from the **git-ignored** file `.env` (template: +`.env.example`, copy it once and fill in the path). An argument takes precedence. Without `-y` it first shows a `--dry-run` preview and asks for confirmation. diff --git a/scripts/deploy-prod.sh b/scripts/deploy-prod.sh index 854f6e3..7a3d7e2 100755 --- a/scripts/deploy-prod.sh +++ b/scripts/deploy-prod.sh @@ -14,8 +14,8 @@ # -y ohne Rückfrage spiegeln (sonst erst Vorschau via --dry-run + Nachfrage) # # Das Ziel ist entweder das Argument ODER — wenn keins angegeben ist — die -# Variable DEPLOY_TARGET aus der git-ignorierten Datei scripts/deploy.env -# (Vorlage: scripts/deploy.env.example). Ein Argument hat Vorrang. +# Variable DEPLOY_TARGET aus der git-ignorierten Datei .env im Repo-Wurzelordner +# (Vorlage: .env.example). Ein Argument hat Vorrang. # # Beispiel (Hostsharing, direkt aufgeschaltete Domain werkbaum.javagil.de — # Web-Verzeichnis in `htdocs-ssl/`; als Subdomain unter einer anderen Domain @@ -51,8 +51,8 @@ done ROOT="$(cd "$(dirname "$0")/.." && pwd)" cd "$ROOT" -# ---- Ziel: Argument hat Vorrang, sonst scripts/deploy.env (git-ignoriert) ---- -ENV_FILE="$ROOT/scripts/deploy.env" +# ---- Ziel: Argument hat Vorrang, sonst DEPLOY_TARGET aus .env (git-ignoriert) ---- +ENV_FILE="$ROOT/.env" if [ -z "$TARGET" ] && [ -f "$ENV_FILE" ]; then # Bewusst NICHT via `source` lesen: bash würde bei `host:~/pfad` das ~ nach dem # ':' LOKAL expandieren. Stattdessen roh auslesen (letzte Definition gewinnt), @@ -62,12 +62,12 @@ if [ -z "$TARGET" ] && [ -f "$ENV_FILE" ]; then | tail -1 | sed -E 's/[[:space:]]+$//')" TARGET="${TARGET#\"}"; TARGET="${TARGET%\"}" TARGET="${TARGET#\'}"; TARGET="${TARGET%\'}" - [ -n "$TARGET" ] && echo "==> Ziel aus scripts/deploy.env: ${TARGET}" + [ -n "$TARGET" ] && echo "==> Ziel aus .env: ${TARGET}" fi if [ -z "$TARGET" ]; then echo "Usage: $0 [-y] " >&2 - echo " oder DEPLOY_TARGET in scripts/deploy.env setzen (Vorlage: scripts/deploy.env.example)" >&2 + echo " oder DEPLOY_TARGET in .env setzen (Vorlage: .env.example)" >&2 echo " z.B. $0 mih00@mih00.hostsharing.net:~/doms/werkbaum.javagil.de/htdocs-ssl" >&2 exit 2 fi diff --git a/scripts/deploy.env.example b/scripts/deploy.env.example deleted file mode 100644 index 1a0a35d..0000000 --- a/scripts/deploy.env.example +++ /dev/null @@ -1,11 +0,0 @@ -# Vorlage für scripts/deploy.env — kopieren und anpassen: -# cp scripts/deploy.env.example scripts/deploy.env -# -# scripts/deploy.env ist git-ignoriert (enthält deinen Server/Pfad) und wird von -# scripts/deploy-prod.sh benutzt, wenn KEIN Ziel als Argument übergeben wird. -# Ein Argument hat immer Vorrang. -# -# Wert = rsync-Ziel (user@host:pfad). Das `~` wird auf der Remote-Seite -# aufgelöst; Anführungszeichen sind optional. Keine Kommentare hinter dem Wert. - -DEPLOY_TARGET=mih00@mih00.hostsharing.net:~/doms/werkbaum.javagil.de/htdocs-ssl