Files
LarsandClaude Opus 5.5 36d51d4c33
Deploy Development / deploy (push) Successful in 55s
Test Suite / pytest-backend (push) Successful in 51s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 17s
Test Suite / k6 /health Baseline (push) Successful in 35s
Test Suite / playwright-tests (push) Failing after 7m46s
Deploy production to llm-node alongside the Pi.
A separate workflow on the linux_host runner deploys main to llm-node with its own checkout, /etc/shinkan/prod.env and a compose override that mounts the NAS media without creating host paths. Media retention stays off there until it is explicitly enabled, because both installations share the media pool. The deploy only passes when /api/health/ready reports a ready database and complete schema. The Pi workflow keeps its name and label and now aborts on any other host.

Also documents both deployments and the recovery contract with the backup orchestrator.

version: 0.8.246 (backend)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-29 15:47:38 +01:00

167 lines
6.4 KiB
YAML

name: Deploy Production llm-node
# Zweites, unabhängiges Prod-Deployment auf llm-node (192.168.2.144, AMD64).
# Läuft parallel zu "Deploy Production" (Raspberry Pi). Den Namen nicht auf
# "Deploy Production" ändern: test.yml hört per workflow_run exakt auf diesen Namen.
# Runner: llm-node-runner mit einzigem Label linux_host (Host-Modus).
# Der Pi-Runner (Raspi5-Paperless) hat nur ubuntu-latest und nimmt diesen Job nie an.
# Compose: docker-compose.yml + docker-compose.llm-node.yml, Konfiguration aus ENV_FILE.
# Doku: .claude/docs/technical/PROD_DEPLOYMENTS.md
on:
push:
branches: [main]
workflow_dispatch:
jobs:
deploy:
runs-on: linux_host
env:
APP_DIR: /home/llmadmin/docker/shinkan-prod
ENV_FILE: /etc/shinkan/prod.env
COMPOSE_PROJECT: shinkan-prod
REPO_URL: http://192.168.2.144:3000/Lars/shinkan-jinkendo.git
MEDIA_HOST: /srv/shinkan/prod/media
# Medienbereinigung (retention-cron): disabled | enabled.
# Pi und llm-node teilen den Medienbestand bei getrennten Datenbanken.
# Nur nach Abschalten der Pi-Bereinigung bzw. dem Cutover auf enabled setzen.
MEDIA_RETENTION: disabled
steps:
- name: Runner prüfen (nur llm-node)
shell: bash
run: |
set -euo pipefail
if [ "$(hostname)" != "llm-node" ] || [ "$(uname -m)" != "x86_64" ]; then
echo "✗ Falscher Runner: $(hostname)/$(uname -m), erwartet llm-node/x86_64. Abbruch."
exit 1
fi
echo "✓ Runner $(hostname)/$(uname -m)"
- name: Konfiguration prüfen
shell: bash
run: |
set -euo pipefail
if [ ! -r "$ENV_FILE" ]; then
echo "✗ $ENV_FILE fehlt oder ist nicht lesbar."
exit 1
fi
env_value() {
grep -E "^$1=" "$ENV_FILE" | tail -1 | cut -d= -f2- | tr -d "\"'" || true
}
if [ -z "$(env_value DB_PASSWORD)" ]; then
echo "✗ DB_PASSWORD ist in $ENV_FILE nicht gesetzt."
exit 1
fi
# Profile steuert allein MEDIA_RETENTION in diesem Workflow.
if grep -Eq "^COMPOSE_PROFILES=" "$ENV_FILE"; then
echo "✗ COMPOSE_PROFILES in $ENV_FILE entfernen; die Bereinigung schaltet MEDIA_RETENTION im Workflow."
exit 1
fi
# Override mountet fest $MEDIA_HOST -> /app/media; abweichende Werte ergäben einen zweiten Mount.
media_host="$(env_value SHINKAN_MEDIA_HOST)"
media_root="$(env_value MEDIA_ROOT)"
if [ -n "$media_host" ] && [ "$media_host" != "$MEDIA_HOST" ]; then
echo "✗ SHINKAN_MEDIA_HOST=$media_host, erwartet $MEDIA_HOST."
exit 1
fi
if [ -n "$media_root" ] && [ "$media_root" != "/app/media" ]; then
echo "✗ MEDIA_ROOT=$media_root, erwartet /app/media."
exit 1
fi
case "$MEDIA_RETENTION" in
disabled|enabled) ;;
*) echo "✗ MEDIA_RETENTION=$MEDIA_RETENTION, erlaubt: disabled | enabled."; exit 1 ;;
esac
echo "✓ $ENV_FILE geprüft, Medien $MEDIA_HOST -> /app/media, Bereinigung $MEDIA_RETENTION"
- name: Code aktualisieren
shell: bash
run: |
set -euo pipefail
cd "$APP_DIR"
if [ ! -d .git ]; then
git init -q
git remote add origin "$REPO_URL"
fi
git fetch origin main
git reset --hard origin/main
git log -1 --oneline
- name: Build und Start
shell: bash
run: |
set -euo pipefail
echo "=== Deploying Shinkan to PRODUCTION (llm-node) ==="
cd "$APP_DIR"
dc() {
docker compose -p "$COMPOSE_PROJECT" -f docker-compose.yml -f docker-compose.llm-node.yml \
--env-file "$ENV_FILE" "$@"
}
if [ "$MEDIA_RETENTION" = enabled ]; then
dc --profile media-retention build --no-cache
dc --profile media-retention up -d --remove-orphans
else
dc build --no-cache
dc up -d --remove-orphans
# Ein früher gestarteter retention-cron läuft sonst weiter.
dc --profile media-retention rm -s -f retention-cron
fi
- name: Healthchecks
shell: bash
run: |
set -euo pipefail
cd "$APP_DIR"
dc() {
docker compose -p "$COMPOSE_PROJECT" -f docker-compose.yml -f docker-compose.llm-node.yml \
--env-file "$ENV_FILE" "$@"
}
wait_for() {
local url="$1" label="$2" i
for i in $(seq 1 60); do
if curl -sf -o /dev/null "$url"; then
echo "✓ $label healthy ($url)"
return 0
fi
sleep 3
done
echo "✗ $label nicht erreichbar ($url)"
return 1
}
# HTTP 200 reicht nicht: status=ready, database=true und schema_complete=true.
wait_ready() {
local url="$1" label="$2" i body=""
for i in $(seq 1 60); do
body="$(curl -sf "$url" || true)"
if [ -n "$body" ] && printf '%s' "$body" \
| jq -e '.status == "ready" and .database == true and .schema_complete == true' >/dev/null 2>&1; then
echo "✓ $label ready ($url)"
return 0
fi
sleep 3
done
echo "✗ $label nicht ready ($url):"
printf '%s' "$body" | jq -c '{status, database, schema_complete}' 2>/dev/null || echo " keine gültige Antwort"
return 1
}
ok=1
wait_for http://127.0.0.1:8003/api/version "PROD API (direkt)" || ok=0
if [ "$ok" = 1 ]; then
wait_ready http://127.0.0.1:8003/api/health/ready "PROD API (direkt)" || ok=0
fi
if [ "$ok" = 1 ]; then
wait_for http://127.0.0.1:3003/api/version "PROD API über Frontend-Nginx" || ok=0
fi
if [ "$ok" = 1 ]; then
wait_ready http://127.0.0.1:3003/api/health/ready "PROD API über Frontend-Nginx" || ok=0
fi
if [ "$ok" = 1 ]; then
wait_for http://127.0.0.1:3003/ "PROD Frontend" || ok=0
fi
if [ "$ok" != 1 ]; then
dc ps || true
dc logs backend --tail 120 || true
exit 1
fi
echo "=== Shinkan PROD Deploy (llm-node) complete ==="