#!/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 [ ...] 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 ..." >&2; exit 2; } # The registratie process (BPMN) and its diploma-eligibility DMN are deployed as SEPARATE Flowable # deployments — the process engine and the DMN engine each own theirs (S-13, ADR-0016). flowable-rest # does not cascade a .dmn bundled in a process .bar into the DMN engine, so we seed both raw files and # let flowable-init deploy each via its own REST app. We stage them in a temp dir and copy its contents. stage_flowable_workflows() { local dir="$1" cp "$here/../workflows/registratie.bpmn" "$here/../workflows/diploma-eligibility.dmn" "$dir/" } 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) d="$(mktemp -d)"; stage_flowable_workflows "$d"; populate rr-fl-bpmn "$d/." ;; *) echo "unknown seed key: $key" >&2; exit 2 ;; esac done