#!/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; } for key in "$@"; do case "$key" in oz) populate rr-oz-config "$here/openzaak/setup_configuration/." ;; kc) populate rr-kc-realms "$here/keycloak/realms/." ;; fl) populate rr-fl-bpmn "$here/../workflows/registratie.bpmn" ;; *) echo "unknown seed key: $key" >&2; exit 2 ;; esac done