Multidatabase in single Postgres Container

This commit is contained in:
2026-03-13 21:28:41 +01:00
parent 68072f1320
commit c2e0d0aade
2 changed files with 38 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
#!/bin/bash
set -e
# Prüfen, ob die Variable gesetzt ist
if [ -n "$POSTGRES_MULTIPLE_DATABASES" ]; then
echo "Erstelle mehrere Datenbanken: $POSTGRES_MULTIPLE_DATABASES"
# Die kommagetrennte Liste aufsplitten und abarbeiten
for db in $(echo $POSTGRES_MULTIPLE_DATABASES | tr ',' ' '); do
echo "Erstelle Datenbank: $db"
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" <<-EOSQL
CREATE DATABASE "$db";
GRANT ALL PRIVILEGES ON DATABASE "$db" TO "$POSTGRES_USER";
EOSQL
done
echo "Alle Datenbanken erfolgreich erstellt!"
fi

21
init-scripts/init_ollama.sh Executable file
View File

@@ -0,0 +1,21 @@
#!/bin/bash
# 1. Starte den Ollama-Server im Hintergrund
/bin/ollama serve &
OLLAMA_PID=$!
# 2. Warte, bis die API erreichbar ist
echo "Warte darauf, dass der Ollama-Server hochfährt..."
while ! curl -s http://localhost:11434/api/tags > /dev/null; do
sleep 2
done
echo "Ollama ist erreichbar! Prüfe/Lade das Modell 'granite4:tiny-h'..."
# 3. Lade das Modell herunter (falls noch nicht vorhanden)
ollama pull granite4:tiny-h
echo "Modell ist einsatzbereit!"
# 4. Halte den Container am Laufen, indem der Ollama-Prozess im Vordergrund gehalten wird
wait $OLLAMA_PID