Files
deklarix/scripts/build.sh
noroot 31caa8f66a feat: add web layer (internal/web) and wire it into main.go
Routing, html/template layout/content pattern, and the Pre-Publish
check flow: POST /pruefen runs extraction (Stufe 1) then rules.Evaluate
(Stufe 2) and renders the result as an htmx fragment. Nothing is
persisted yet — that's the next step (wiring internal/store in).

The needsClarification case is rendered explicitly as a request for
more information rather than "no findings", matching the core
principle. Every result carries the legal-advice disclaimer required by
CLAUDE.md's guardrails.

Server depends on a narrow Extractor interface rather than *extract.
Client directly, so tests inject a fake instead of calling the real API
— internal/web's test suite never touches the network. htmx is vendored
locally (internal/web/static/htmx.min.js) instead of loaded from a CDN,
keeping the UI usable without runtime internet access.

cmd/deklarix/main.go now wires all of this together: reads
ANTHROPIC_API_KEY (required) and RULES_DIR (default "rules"), builds
the extract client and loads the rule set, and serves web.Server instead
of the old inline health-only mux.

This exposed the same crash-loop risk fixed earlier for DATABASE_URL:
postinst's start guard only checked DATABASE_URL, so a fresh install
would now crash-loop on a missing ANTHROPIC_API_KEY instead. The guard
checks both. scripts/build.sh also now ships rules/*.yaml into the .deb
under /usr/share/deklarix/rules (not a conffile — rules are updated via
the release pipeline, never hand-edited on a server), and
deklarix.env.example points RULES_DIR there by default.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-27 14:23:45 +02:00

76 lines
2.5 KiB
Bash
Executable File

#!/usr/bin/env bash
# Deklarix — .deb-Pakete bauen (amd64 + arm64)
#
# Verwendung:
# ./scripts/build.sh [version] # Beide Architekturen
# ./scripts/build.sh [version] amd64 # Nur amd64
# ./scripts/build.sh [version] arm64 # Nur arm64
#
# Ausgabe: dist/deklarix_<version>_<arch>.deb
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
REPO_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
PACKAGING_DIR="$REPO_DIR/packaging"
BUILD_DIR="$REPO_DIR/dist/build"
VERSION="${1:-0.0.1}"
ARCH_FILTER="${2:-both}"
GRN='\033[0;32m'; BLD='\033[1m'; NC='\033[0m'
log() { echo -e "${GRN}[build]${NC} $*"; }
export PATH=$PATH:/usr/local/go/bin
command -v go >/dev/null || { echo "Go nicht gefunden — PATH: $PATH"; exit 1; }
command -v dpkg-deb >/dev/null || { echo "dpkg-deb nicht gefunden"; exit 1; }
log "Version: $VERSION | Go: $(go version)"
ARCHS=()
case "$ARCH_FILTER" in
amd64) ARCHS=("amd64") ;;
arm64) ARCHS=("arm64") ;;
*) ARCHS=("amd64" "arm64") ;;
esac
rm -rf "$BUILD_DIR"
mkdir -p "$REPO_DIR/dist"
for ARCH in "${ARCHS[@]}"; do
DEB_NAME="deklarix_${VERSION}_${ARCH}"
DEB_DIR="$BUILD_DIR/$DEB_NAME"
log "Baue Binary ($ARCH)..."
mkdir -p "$DEB_DIR/DEBIAN" \
"$DEB_DIR/usr/bin" \
"$DEB_DIR/usr/share/deklarix/rules" \
"$DEB_DIR/etc/systemd/system" \
"$DEB_DIR/etc/deklarix"
CGO_ENABLED=0 GOARCH=$ARCH GOOS=linux go build \
-trimpath -ldflags="-X main.Version=${VERSION} -s -w" \
-o "$DEB_DIR/usr/bin/deklarix" \
./cmd/deklarix/
chmod 755 "$DEB_DIR/usr/bin/deklarix"
log "Stelle Paket zusammen ($ARCH)..."
sed "s/^Version: VERSION/Version: $VERSION/; s/^Architecture: ARCH/Architecture: $ARCH/" \
"$PACKAGING_DIR/DEBIAN/control.tmpl" > "$DEB_DIR/DEBIAN/control"
cp "$PACKAGING_DIR/DEBIAN/postinst" "$DEB_DIR/DEBIAN/postinst"
cp "$PACKAGING_DIR/DEBIAN/prerm" "$DEB_DIR/DEBIAN/prerm"
cp "$PACKAGING_DIR/DEBIAN/conffiles" "$DEB_DIR/DEBIAN/conffiles"
chmod 755 "$DEB_DIR/DEBIAN/postinst" "$DEB_DIR/DEBIAN/prerm"
cp "$PACKAGING_DIR/etc/systemd/system/deklarix.service" "$DEB_DIR/etc/systemd/system/"
cp "$PACKAGING_DIR/etc/deklarix/deklarix.env.example" "$DEB_DIR/etc/deklarix/"
cp "$REPO_DIR"/rules/*.yaml "$DEB_DIR/usr/share/deklarix/rules/"
dpkg-deb --build --root-owner-group "$DEB_DIR" "$REPO_DIR/dist/$DEB_NAME.deb"
log "$ARCH fertig: dist/$DEB_NAME.deb ($(du -sh "$REPO_DIR/dist/$DEB_NAME.deb" | cut -f1))"
done
rm -rf "$BUILD_DIR"
log "Build abgeschlossen ✓"