Files
register-referentie/infra/seed-config.sh
Niek Otten d5100d9d41
Some checks failed
CI / lint (pull_request) Successful in 1m17s
CI / build (pull_request) Successful in 55s
CI / unit (pull_request) Successful in 1m8s
CI / frontend (pull_request) Successful in 2m31s
CI / mutation (pull_request) Successful in 5m11s
CI / verify-stack (pull_request) Failing after 7m44s
fix(infra): deploy BPMN + DMN as one .bar so the inline decision resolves (S-13, refs #14)
The DMN service task resolves its decision scoped to the process's own deployment,
so a standalone .dmn deployment was invisible (FlowableObjectNotFoundException: No
decision found for key: diploma-eligibility). Bundle registratie.bpmn +
diploma-eligibility.dmn into a single registratie.bar and deploy it as one
deployment, giving the decision the process's parent deployment id. flowable-rest
does not expose the dmn-api app, so co-deployment is the way in.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-18 11:38:44 +02:00

61 lines
2.8 KiB
Bash
Executable File

#!/usr/bin/env bash
#
# Populate the external named *config* volumes that the upstream services mount,
# by `docker cp`-ing files into a throwaway helper container that mounts each one.
#
# Why: the compose stack uses the upstream images verbatim (no build). On Gitea's
# containerized runner, `docker compose` starts the stack as SIBLING containers
# via the host daemon, so a workspace bind mount resolves to a path the daemon
# can't see and is mounted empty. `docker cp` instead streams bytes over the
# Docker API, so the files reach the volume regardless of where the daemon runs.
# We use plain docker primitives (volume create / run / cp / rm) rather than
# `docker compose create`, because podman-compose (local dev) lacks that
# subcommand. Fixed-name `external` volumes keep the names deterministic across
# both runtimes. See docs/runbooks/gitea-actions-gotchas.md.
#
# Usage: seed-config.sh <key> [<key> ...] where key ∈ { oz, kc, fl }
set -euo pipefail
here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
HELPER="${SEED_HELPER_IMAGE:-docker.io/library/busybox:stable}"
populate() { # volume source(file or dir/.)
local vol="$1" src="$2" cid
docker volume rm -f "$vol" >/dev/null 2>&1 || true
docker volume create "$vol" >/dev/null
# A *created* (never started) helper is enough: the volume is attached at create
# time, `docker cp` writes through to it, and `docker rm` is instant (nothing to
# stop). `docker create` is a container subcommand both docker and podman have —
# unlike `docker compose create`, which podman-compose lacks.
cid="$(docker create -v "$vol:/dest" "$HELPER" true)"
docker cp "$src" "$cid:/dest/"
docker rm "$cid" >/dev/null
echo " seeded $vol"
}
[ "$#" -gt 0 ] || { echo "usage: seed-config.sh <oz|nrc|kc|fl> ..." >&2; exit 2; }
# The registratie process and its diploma-eligibility DMN must land in ONE Flowable deployment, so the
# process's inline DMN service task resolves the decision by its (shared) parent deployment id (S-13,
# ADR-0016). We bundle both into a single .bar (zip) and deploy that one artefact.
build_flowable_bar() {
local out="$1"
python3 - "$here/../workflows/registratie.bpmn" "$here/../workflows/diploma-eligibility.dmn" "$out" <<'PY'
import sys, zipfile
bpmn, dmn, out = sys.argv[1:4]
with zipfile.ZipFile(out, "w", zipfile.ZIP_DEFLATED) as z:
z.write(bpmn, "registratie.bpmn")
z.write(dmn, "diploma-eligibility.dmn")
PY
}
for key in "$@"; do
case "$key" in
oz) populate rr-oz-config "$here/openzaak/setup_configuration/." ;;
nrc) populate rr-nrc-config "$here/opennotificaties/setup_configuration/." ;;
kc) populate rr-kc-realms "$here/keycloak/realms/." ;;
fl) bar="$(mktemp -d)/registratie.bar"; build_flowable_bar "$bar"; populate rr-fl-bpmn "$bar" ;;
*) echo "unknown seed key: $key" >&2; exit 2 ;;
esac
done