Files
pdf_to_ics/deploy.sh

59 lines
1.6 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
COMPOSE_FILE="docker-compose.deploy.yml"
if ! command -v docker >/dev/null 2>&1; then
echo "❌ Fehler: docker ist nicht installiert oder nicht im PATH."
exit 1
fi
if ! docker compose version >/dev/null 2>&1; then
echo "❌ Fehler: docker compose ist nicht verfügbar."
exit 1
fi
if [ ! -f "$COMPOSE_FILE" ]; then
echo "❌ Fehler: $COMPOSE_FILE nicht gefunden."
exit 1
fi
if [ ! -f ".env" ]; then
if [ -f ".env.example" ]; then
cp .env.example .env
echo " .env wurde aus .env.example erstellt. Bitte Werte prüfen."
else
echo "❌ Fehler: .env fehlt und keine .env.example vorhanden."
exit 1
fi
fi
IMAGE_REF="$(docker compose -f "$COMPOSE_FILE" config | awk '/image:/{print $2; exit}')"
if [ -z "$IMAGE_REF" ]; then
echo "❌ Fehler: Kein Image in $COMPOSE_FILE gefunden."
exit 1
fi
echo "⬇️ Lade Container-Image..."
if docker compose -f "$COMPOSE_FILE" pull; then
echo "✅ Image-Pull erfolgreich."
else
echo "⚠️ Image-Pull fehlgeschlagen. Prüfe lokales Image: $IMAGE_REF"
if docker image inspect "$IMAGE_REF" >/dev/null 2>&1; then
echo "✅ Lokales Image gefunden. Deployment läuft mit lokalem Image weiter."
else
echo "❌ Weder Registry-Pull erfolgreich noch lokales Image vorhanden: $IMAGE_REF"
echo " Bitte Registry-Zugriff prüfen oder ein lokales Image mit genau diesem Tag bereitstellen."
exit 1
fi
fi
echo "🚀 Starte Container..."
docker compose -f "$COMPOSE_FILE" up -d
echo "✅ Deployment abgeschlossen."
docker compose -f "$COMPOSE_FILE" ps