feat(deploy): Image-Promotion, deploy.env, Health-Check-Fix und Anleitungen
- Deploy-Scripts: Image-Promotion statt Rebuild (docker tag + up -d), deploy.env fuer Server-Konfiguration, -p fuer Projekt-Namen, Health-Check mit Host-Header und /xhr/health-check - docker-compose.prod.yaml: name-Feld entfernt (Projekt-Name per -p) - deploy.env.example als Vorlage hinzugefuegt - .vibe/skills/client-build/SKILL.md aus Git-Index entfernt (gitignore) - Deployment-Anleitung: Zugangsdaten, deploy.env, Image-Promotion, prod ohne eigenes Repo, git-clone-Hinweis, Log-Befehle mit -p - Deploy-lokal-testen.md: neue Anleitung fuer lokales Testen Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
1 parent
e824b545bb
commit
efef212544
7 files changed
+440
-106
No files matched your search
Regular → Executable
+37
-7
@@ -2,13 +2,39 @@
|
||||
# Deploy-Script: Automatisches Deployment nach TEST (test-prod)
|
||||
# Wird durch Git-Hook/Webhook oder manuell aufgerufen.
|
||||
# Voraussetzungen auf dem Server: git, docker, docker compose.
|
||||
#
|
||||
# Server-spezifische Konfiguration (Pfade, Ports, Projekt-Namen) wird aus
|
||||
# einer Datei deploy.env geladen, die im gleichen Verzeichnis wie dieses
|
||||
# Script liegen muss. Diese Datei ist NICHT Teil des Repos und wird nicht
|
||||
# per git pull ueberschrieben. Die Defaults unten greifen, falls deploy.env
|
||||
# fehlt oder einzelne Werte nicht setzt.
|
||||
set -euo pipefail
|
||||
|
||||
# Konfiguration — an die jeweilige Server-Umgebung anpassen
|
||||
REPO_DIR=/opt/kbcrm-test/repo
|
||||
# === Script-Verzeichnis ermitteln (fuer deploy.env) ===
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
# === Server-Konfiguration laden (ausserhalb des Repos, nicht per git pull ueberschreibbar) ===
|
||||
DEPLOY_CONFIG="$SCRIPT_DIR/deploy.env"
|
||||
if [ -f "$DEPLOY_CONFIG" ]; then
|
||||
source "$DEPLOY_CONFIG"
|
||||
fi
|
||||
|
||||
# === Defaults — werden verwendet, falls deploy.env fehlt oder Werte nicht setzt ===
|
||||
REPO_DIR="${DEPLOY_REPO_DIR:-/opt/kbcrm/test-prod/repo}"
|
||||
COMPOSE_FILE=docker-compose.prod.yaml
|
||||
ENV_FILE=/opt/kbcrm-test/.env
|
||||
TEST_PORT=8443
|
||||
ENV_FILE="${DEPLOY_ENV_FILE:-/opt/kbcrm/test-prod/.env}"
|
||||
PROJECT_NAME="${DEPLOY_PROJECT_NAME:-kbptest}"
|
||||
HEALTH_PORT="${DEPLOY_HEALTH_PORT:-8443}"
|
||||
|
||||
# === NGINX_SERVER_NAME aus .env laden (fuer Health-Check Host-Header) ===
|
||||
# Die .env wird per --env-file an Docker Compose uebergeben, aber die Variablen
|
||||
# stehen nicht als Shell-Variablen im Script zur Verfuegung. Daher laden wir
|
||||
# NGINX_SERVER_NAME manuell, damit der Health-Check den richtigen Host-Header
|
||||
# sendet (sonst liefert NGINX 404 wegen server_name-Mismatch).
|
||||
NGINX_SERVER_NAME=""
|
||||
if [ -f "$ENV_FILE" ]; then
|
||||
NGINX_SERVER_NAME=$(grep -E "^NGINX_SERVER_NAME=" "$ENV_FILE" | cut -d= -f2- | tr -d '\r\n')
|
||||
fi
|
||||
|
||||
echo "=== Deploy KB-CRM TEST ==="
|
||||
|
||||
@@ -20,17 +46,21 @@ git checkout main
|
||||
git reset --hard origin/main
|
||||
|
||||
# 2. Images neu bauen und Container starten
|
||||
# -p setzt den Projekt-Namen (fuer Image-Namen und Container-Namen)
|
||||
# --env-file laedt die Container-Variablen (Ports, Zertifikate, DB, OIDC)
|
||||
# -f gibt die Compose-Datei explizit an (ignoriert COMPOSE_FILE aus .env)
|
||||
echo "=== Building and starting containers ==="
|
||||
docker compose --env-file "$ENV_FILE" -f "$COMPOSE_FILE" up -d --build
|
||||
docker compose -p "$PROJECT_NAME" --env-file "$ENV_FILE" \
|
||||
-f "$COMPOSE_FILE" up -d --build
|
||||
|
||||
# 3. Health-Check
|
||||
echo "=== Waiting for container startup ==="
|
||||
sleep 10
|
||||
if curl -sf "http://localhost:${TEST_PORT}/health-check" >/dev/null 2>&1; then
|
||||
if curl -sf -H "Host: ${NGINX_SERVER_NAME}" "http://localhost:${HEALTH_PORT}/xhr/health-check" >/dev/null 2>&1; then
|
||||
echo "Health check: OK"
|
||||
else
|
||||
echo "WARNING: Health check failed — check container logs with:"
|
||||
echo " docker compose --env-file $ENV_FILE -f $COMPOSE_FILE logs"
|
||||
echo " docker compose -p $PROJECT_NAME --env-file $ENV_FILE -f $COMPOSE_FILE logs"
|
||||
fi
|
||||
|
||||
echo "=== Deploy TEST complete ==="
|
||||
Reference in new issue
Block a user