Run the containers with the systemd configuration, 1:1

The containers now read the unchanged .env of the matching systemd instance
(/home/llmadmin/mindnet_dev/.env, /home/llmadmin/mindnet/.env) and use the
same Qdrant, Ollama, vault and collection prefix, so both can be compared
side by side. Only container-specific values are overridden: host service
addresses (host.docker.internal instead of 127.0.0.1) and the read-only vault.

- deploy/appenv.py derives the vault mount and prefix from that .env and
  rejects application keys in the container-only file.
- Remove the separate dev Qdrant, the synthetic test vault and the import step.
- UI binds 0.0.0.0 like systemd; API stays loopback by default.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
LarsandClaude Opus 5.5 committed 2026-10-28 17:22:08 +01:00
1 parent eae30775e3
commit 6cdad8b046
20 files changed
+373 -415

No files matched your search

+22 -19
View File
@@ -2,7 +2,10 @@
# Baut, prüft und startet einen Mindnet-Container-Stack. Genutzt von den
# Gitea-Workflows (develop -> dev, main -> prod) und für manuelle Deploys.
#
# MINDNET_ENV_FILE=/home/llmadmin/docker/mindnet-dev/dev.env deploy/deploy.sh dev
# MINDNET_APP_ENV_FILE=/home/llmadmin/mindnet_dev/.env # MINDNET_ENV_FILE=/home/llmadmin/docker/mindnet-dev/container.env deploy/deploy.sh dev
#
# MINDNET_APP_ENV_FILE ist die unveränderte .env der systemd-Instanz (gleiche Konfiguration),
# MINDNET_ENV_FILE enthält nur Container-Angaben (deploy/env/<env>.env.example).
#
# Ablauf (jeder Schritt bricht ab, bevor der laufende Stack angefasst wird):
# 1. Container-Tests im Test-Image, ohne Netzwerk (blockierend)
@@ -12,7 +15,7 @@
# 5. up --wait (Healthchecks), danach smoke.py über die veröffentlichten Ports
# 6. Prod: bei Fehler Rückkehr zum letzten erfolgreichen Tag
#
# Die env-Datei liegt auf dem Host außerhalb von Git; in ihrem Verzeichnis
# Beide Dateien liegen auf dem Host außerhalb von Git; im Verzeichnis der Container-Datei
# merkt sich das Skript den letzten erfolgreichen Image-Tag (last_good_tag).
set -euo pipefail
cd "$(dirname "$0")/.."
@@ -22,24 +25,24 @@ case "$ENV" in
dev|prod) ;;
*) echo "Aufruf: deploy/deploy.sh dev|prod" >&2; exit 2 ;;
esac
: "${MINDNET_ENV_FILE:?MINDNET_ENV_FILE auf die env-Datei des Hosts setzen}"
[ -f "$MINDNET_ENV_FILE" ] || { echo "env-Datei fehlt: $MINDNET_ENV_FILE" >&2; exit 1; }
export MINDNET_ENV_FILE
: "${MINDNET_APP_ENV_FILE:?MINDNET_APP_ENV_FILE auf die .env der systemd-Instanz setzen}"
: "${MINDNET_ENV_FILE:?MINDNET_ENV_FILE auf die Container-Datei des Hosts setzen}"
for f in "$MINDNET_APP_ENV_FILE" "$MINDNET_ENV_FILE"; do
[ -f "$f" ] || { echo "env-Datei fehlt: $f" >&2; exit 1; }
done
export MINDNET_APP_ENV_FILE MINDNET_ENV_FILE
# Vault-Mount und Präfix aus der systemd-.env ableiten (gleiches Verzeichnis wie heute).
DERIVED="$(python3 deploy/appenv.py "$MINDNET_APP_ENV_FILE" "$MINDNET_ENV_FILE")"
eval "$DERIVED"
export MINDNET_VAULT_HOST_PATH MINDNET_VAULT_TARGET
PREFIX="$MINDNET_EXPECTED_PREFIX"
echo "$DERIVED"
SHA="$(git rev-parse --short=12 HEAD)"
export MINDNET_IMAGE_TAG="$ENV-$SHA"
LAST_GOOD="$(dirname "$MINDNET_ENV_FILE")/last_good_tag"
if [ "$ENV" = dev ]; then
PREFIX=mindnet_dev
RUN_DEPS=() # startet die eigene Dev-Qdrant für den Preflight mit
SMOKE_ARGS=()
else
PREFIX="$(sed -n 's/^COLLECTION_PREFIX=//p' "$MINDNET_ENV_FILE" | tail -n 1)"
RUN_DEPS=(--no-deps) # Prod hat keine eigene Qdrant
SMOKE_ARGS=(--require-data)
fi
dc() { docker compose -f "deploy/compose.$ENV.yml" --env-file "$MINDNET_ENV_FILE" "$@"; }
step() { printf '\n=== %s\n' "$*"; }
show_logs() { dc ps || true; dc logs --tail 150 api ui || true; }
@@ -47,7 +50,7 @@ published() { dc port "$1" "$2" | head -n 1 | sed 's/^0\.0\.0\.0:/127.0.0.1:/';
smoke() {
python3 deploy/smoke.py --api "http://$(published api 8000)" --ui "http://$(published ui 8501)" \
--prefix "$PREFIX" "${SMOKE_ARGS[@]}"
--prefix "$PREFIX" --require-data
}
step "1/5 Container-Tests (ohne Netzwerk)"
@@ -65,10 +68,10 @@ step "3/5 Image bauen ($MINDNET_IMAGE_TAG)"
dc build api ui
step "4/5 Preflight mit Erreichbarkeit (nur lesend)"
dc run --rm "${RUN_DEPS[@]}" api preflight --live
dc run --rm --no-deps api preflight --live
step "5/5 Start ($MINDNET_IMAGE_TAG) und Smoke"
if dc up -d --wait --no-build && smoke; then
if dc up -d --wait --no-build --remove-orphans && smoke; then
echo "$MINDNET_IMAGE_TAG" > "$LAST_GOOD"
echo "=== mindnet-$ENV läuft mit $MINDNET_IMAGE_TAG"
exit 0
@@ -79,7 +82,7 @@ PREV="$(cat "$LAST_GOOD" 2>/dev/null || true)"
if [ "$ENV" = prod ] && [ -n "$PREV" ] && [ "$PREV" != "$MINDNET_IMAGE_TAG" ]; then
step "Rollback auf $PREV"
export MINDNET_IMAGE_TAG="$PREV"
if dc up -d --wait --no-build && smoke; then
if dc up -d --wait --no-build --remove-orphans && smoke; then
echo "Rollback erfolgreich; Deploy von $ENV-$SHA ist trotzdem fehlgeschlagen."
else
show_logs