#!/bin/bash # Deploy-Script: Automatisches Deployment nach TEST (test-prod) # Wird durch Git-Hook/Webhook oder manuell aufgerufen. # Voraussetzungen auf dem Server: git, docker, docker compose. set -euo pipefail # Konfiguration — an die jeweilige Server-Umgebung anpassen REPO_DIR=/opt/kbcrm-test/repo COMPOSE_FILE=docker-compose.prod.yaml ENV_FILE=/opt/kbcrm-test/.env TEST_PORT=8443 echo "=== Deploy KB-CRM TEST ===" # 1. Code aktualisieren cd "$REPO_DIR" echo "=== Pulling latest code ===" git fetch origin main git checkout main git reset --hard origin/main # 2. Images neu bauen und Container starten echo "=== Building and starting containers ===" docker compose --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 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" fi echo "=== Deploy TEST complete ==="