docs: add guide for Git-based deployment on Zora and deployment script
Introduced a comprehensive guide on setting up Git-based deployment for the "Zora" server, including environment setup, repository initialization, and deployment workflow. Added `deploy.sh` script to streamline updates and restarts.
This commit is contained in:
parent
9b40f84e40
commit
d142f2da0e
22
config/scripts/deploy.sh
Normal file
22
config/scripts/deploy.sh
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
#!/bin/bash
|
||||
# deploy.sh - Update & Restart Meldestelle Stack
|
||||
|
||||
echo "🚀 Starte Deployment..."
|
||||
|
||||
# 1. Neueste Konfiguration holen
|
||||
echo " -> Git Pull..."
|
||||
git pull origin main
|
||||
|
||||
# 2. Neue Images laden
|
||||
echo " -> Docker Pull..."
|
||||
docker compose pull
|
||||
|
||||
# 3. Container neu starten (nur geänderte)
|
||||
echo " -> Docker Up..."
|
||||
docker compose up -d --remove-orphans
|
||||
|
||||
# 4. Aufräumen
|
||||
echo " -> Pruning old images..."
|
||||
docker image prune -f
|
||||
|
||||
echo "✅ Deployment erfolgreich!"
|
||||
129
docs/07_Infrastructure/Guides/Setup_Git_Deployment_Zora.md
Normal file
129
docs/07_Infrastructure/Guides/Setup_Git_Deployment_Zora.md
Normal file
|
|
@ -0,0 +1,129 @@
|
|||
---
|
||||
type: Guide
|
||||
status: ACTIVE
|
||||
owner: DevOps Engineer
|
||||
last_update: 2026-03-05
|
||||
tags: [deployment, git, zora, docker]
|
||||
---
|
||||
|
||||
# 🚀 Guide: Git-basiertes Deployment auf Zora einrichten
|
||||
|
||||
Dieser Guide beschreibt, wie du den Produktions-Server "Zora" so konfigurierst, dass er Updates direkt aus dem Gitea-Repository zieht. Dies stellt sicher, dass nicht nur die Docker-Images, sondern auch die `docker-compose.yaml` Konfigurationen immer synchron sind.
|
||||
|
||||
## 📋 Voraussetzungen
|
||||
|
||||
* SSH-Zugriff auf Zora (`ssh user@10.0.0.xx`).
|
||||
* `git` und `docker` sind auf Zora installiert.
|
||||
* Ein Gitea-Account mit Zugriff auf das `meldestelle` Repository.
|
||||
|
||||
---
|
||||
|
||||
## 🛠️ Schritt-für-Schritt Anleitung
|
||||
|
||||
### 1. Projektverzeichnis vorbereiten
|
||||
|
||||
Verbinde dich mit Zora und gehe in das Zielverzeichnis:
|
||||
|
||||
```bash
|
||||
ssh user@zora-ip
|
||||
cd ~/meldestelle
|
||||
```
|
||||
|
||||
**WICHTIG:** Falls dort bereits Konfigurationsdateien liegen, erstelle ein Backup:
|
||||
|
||||
```bash
|
||||
mkdir -p ../backup_meldestelle_$(date +%F)
|
||||
cp * ../backup_meldestelle_$(date +%F)/
|
||||
```
|
||||
|
||||
### 2. Git-Repository initialisieren
|
||||
|
||||
Wir verwandeln den Ordner in ein Git-Repo, das mit Gitea verknüpft ist.
|
||||
|
||||
```bash
|
||||
# Git initialisieren
|
||||
git init
|
||||
|
||||
# Remote Origin hinzufügen (HTTPS)
|
||||
git remote add origin https://git.mo-code.at/mocode-software/meldestelle.git
|
||||
|
||||
# Neueste Änderungen holen
|
||||
git fetch origin
|
||||
|
||||
# Hard Reset auf den main-Branch (ACHTUNG: Überschreibt lokale Änderungen!)
|
||||
git reset --hard origin/main
|
||||
```
|
||||
|
||||
*Jetzt sollten alle `dc-*.yaml` Dateien und Skripte im Ordner liegen.*
|
||||
|
||||
### 3. Environment-Variablen (.env) konfigurieren
|
||||
|
||||
Die `.env` Datei enthält Geheimnisse und wird **nicht** in Git gespeichert.
|
||||
|
||||
1. Kopiere die Vorlage:
|
||||
```bash
|
||||
cp .env.example .env
|
||||
```
|
||||
|
||||
2. Bearbeite die Datei:
|
||||
```bash
|
||||
nano .env
|
||||
```
|
||||
|
||||
3. **Wichtige Anpassungen für Production:**
|
||||
* `KC_HOSTNAME=auth.mo-code.at`
|
||||
* `KC_ISSUER_URI=https://auth.mo-code.at/realms/meldestelle`
|
||||
* `KC_JWK_SET_URI=http://keycloak:8080/realms/meldestelle/protocol/openid-connect/certs`
|
||||
* Setze starke Passwörter für Datenbank, Keycloak und Grafana!
|
||||
|
||||
### 4. Deployment-Skript einrichten
|
||||
|
||||
Das Skript `config/scripts/deploy.sh` liegt nun im Repo bereit (sobald wir es gepusht haben).
|
||||
Du kannst es direkt nutzen oder manuell anlegen:
|
||||
|
||||
**Inhalt von `deploy.sh`:**
|
||||
|
||||
```bash
|
||||
#!/bin/bash
|
||||
# deploy.sh - Update & Restart Meldestelle Stack
|
||||
|
||||
echo "🚀 Starte Deployment..."
|
||||
|
||||
# 1. Neueste Konfiguration holen
|
||||
echo " -> Git Pull..."
|
||||
git pull origin main
|
||||
|
||||
# 2. Neue Images laden
|
||||
echo " -> Docker Pull..."
|
||||
docker compose pull
|
||||
|
||||
# 3. Container neu starten (nur geänderte)
|
||||
echo " -> Docker Up..."
|
||||
docker compose up -d --remove-orphans
|
||||
|
||||
# 4. Aufräumen
|
||||
echo " -> Pruning old images..."
|
||||
docker image prune -f
|
||||
|
||||
echo "✅ Deployment erfolgreich!"
|
||||
```
|
||||
|
||||
Mache das Skript ausführbar:
|
||||
|
||||
```bash
|
||||
chmod +x config/scripts/deploy.sh
|
||||
# Optional: Symlink ins Root
|
||||
ln -s config/scripts/deploy.sh deploy.sh
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🔄 Workflow für Updates
|
||||
|
||||
Wenn du Code oder Konfiguration gepusht hast und die CI-Pipeline durchgelaufen ist:
|
||||
|
||||
1. SSH auf Zora.
|
||||
2. `cd ~/meldestelle`
|
||||
3. `./deploy.sh`
|
||||
|
||||
Das System ist nun auf dem neuesten Stand!
|
||||
Loading…
Reference in New Issue
Block a user