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 <noreply@anthropic.com>
This commit is contained in:
mhoennig
2026-07-22 07:15:32 +02:00
co-authored by Claude Opus 4.8
parent 6b83af7d73
commit 350b0db7ee
6 changed files with 22 additions and 23 deletions
+11
View File
@@ -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
+1 -2
View File
@@ -57,11 +57,10 @@ frontend/node_modules/
frontend/dist/ frontend/dist/
# === Geheimnisse / lokale Umgebung === # === Geheimnisse / lokale Umgebung ===
# .env hält u. a. DEPLOY_TARGET für scripts/deploy-prod.sh (Vorlage: .env.example)
.env .env
.env.local .env.local
*.local *.local
# Deploy-Ziel (scripts/deploy-prod.sh) — lokal halten; Vorlage .example bleibt drin
scripts/deploy.env
# === Temporäres === # === Temporäres ===
tmp/ tmp/
+2 -2
View File
@@ -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 Das Ziel ist entweder dieses Argument oder — ohne Argument — die Variable
`DEPLOY_TARGET` aus der **git-ignorierten** Datei `scripts/deploy.env` (Vorlage: `DEPLOY_TARGET` aus der **git-ignorierten** Datei `.env` (Vorlage:
`scripts/deploy.env.example`, einmal kopieren und den Pfad eintragen). Ein `.env.example`, einmal kopieren und den Pfad eintragen). Ein
Argument hat Vorrang. Argument hat Vorrang.
Ohne `-y` zeigt es zuerst eine `--dry-run`-Vorschau und fragt nach. `rsync Ohne `-y` zeigt es zuerst eine `--dry-run`-Vorschau und fragt nach. `rsync
+2 -2
View File
@@ -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` The target is either this argument or — with no argument — the `DEPLOY_TARGET`
variable from the **git-ignored** file `scripts/deploy.env` (template: variable from the **git-ignored** file `.env` (template:
`scripts/deploy.env.example`, copy it once and fill in the path). An argument `.env.example`, copy it once and fill in the path). An argument
takes precedence. takes precedence.
Without `-y` it first shows a `--dry-run` preview and asks for confirmation. Without `-y` it first shows a `--dry-run` preview and asks for confirmation.
+6 -6
View File
@@ -14,8 +14,8 @@
# -y ohne Rückfrage spiegeln (sonst erst Vorschau via --dry-run + Nachfrage) # -y ohne Rückfrage spiegeln (sonst erst Vorschau via --dry-run + Nachfrage)
# #
# Das Ziel ist entweder das Argument ODER — wenn keins angegeben ist — die # Das Ziel ist entweder das Argument ODER — wenn keins angegeben ist — die
# Variable DEPLOY_TARGET aus der git-ignorierten Datei scripts/deploy.env # Variable DEPLOY_TARGET aus der git-ignorierten Datei .env im Repo-Wurzelordner
# (Vorlage: scripts/deploy.env.example). Ein Argument hat Vorrang. # (Vorlage: .env.example). Ein Argument hat Vorrang.
# #
# Beispiel (Hostsharing, direkt aufgeschaltete Domain werkbaum.javagil.de — # Beispiel (Hostsharing, direkt aufgeschaltete Domain werkbaum.javagil.de —
# Web-Verzeichnis in `htdocs-ssl/`; als Subdomain unter einer anderen Domain # Web-Verzeichnis in `htdocs-ssl/`; als Subdomain unter einer anderen Domain
@@ -51,8 +51,8 @@ done
ROOT="$(cd "$(dirname "$0")/.." && pwd)" ROOT="$(cd "$(dirname "$0")/.." && pwd)"
cd "$ROOT" cd "$ROOT"
# ---- Ziel: Argument hat Vorrang, sonst scripts/deploy.env (git-ignoriert) ---- # ---- Ziel: Argument hat Vorrang, sonst DEPLOY_TARGET aus .env (git-ignoriert) ----
ENV_FILE="$ROOT/scripts/deploy.env" ENV_FILE="$ROOT/.env"
if [ -z "$TARGET" ] && [ -f "$ENV_FILE" ]; then if [ -z "$TARGET" ] && [ -f "$ENV_FILE" ]; then
# Bewusst NICHT via `source` lesen: bash würde bei `host:~/pfad` das ~ nach dem # Bewusst NICHT via `source` lesen: bash würde bei `host:~/pfad` das ~ nach dem
# ':' LOKAL expandieren. Stattdessen roh auslesen (letzte Definition gewinnt), # ':' 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:]]+$//')" | tail -1 | sed -E 's/[[:space:]]+$//')"
TARGET="${TARGET#\"}"; TARGET="${TARGET%\"}" TARGET="${TARGET#\"}"; TARGET="${TARGET%\"}"
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 fi
if [ -z "$TARGET" ]; then if [ -z "$TARGET" ]; then
echo "Usage: $0 [-y] <rsync-ziel>" >&2 echo "Usage: $0 [-y] <rsync-ziel>" >&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 echo " z.B. $0 mih00@mih00.hostsharing.net:~/doms/werkbaum.javagil.de/htdocs-ssl" >&2
exit 2 exit 2
fi fi
-11
View File
@@ -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