diff --git a/.gitea/workflows/ci.yaml b/.gitea/workflows/ci.yaml index 2f0be4c..6774463 100644 --- a/.gitea/workflows/ci.yaml +++ b/.gitea/workflows/ci.yaml @@ -17,7 +17,7 @@ permissions: jobs: lint: - runs-on: respellion-linux + runs-on: ubuntu-latest steps: - uses: https://github.com/actions/checkout@v4 - uses: https://github.com/actions/setup-dotnet@v4 @@ -26,7 +26,7 @@ jobs: - run: make lint build: - runs-on: respellion-linux + runs-on: ubuntu-latest steps: - uses: https://github.com/actions/checkout@v4 - uses: https://github.com/actions/setup-dotnet@v4 @@ -35,7 +35,7 @@ jobs: - run: make build unit: - runs-on: respellion-linux + runs-on: ubuntu-latest steps: - uses: https://github.com/actions/checkout@v4 - uses: https://github.com/actions/setup-dotnet@v4 @@ -44,7 +44,13 @@ jobs: - run: make unit compose-smoke: - runs-on: respellion-linux + runs-on: ubuntu-latest steps: - uses: https://github.com/actions/checkout@v4 - run: make smoke + - name: dump container logs on failure + if: failure() + run: docker compose -f infra/docker-compose.yml logs --no-color --tail=80 oz-init openzaak nrc-init nrc-web flowable-init keycloak acl bff 2>&1 || true + - name: tear down on failure + if: failure() + run: docker compose -f infra/docker-compose.yml down --volumes 2>&1 || true diff --git a/Makefile b/Makefile index 49442f5..403475b 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,22 @@ SLN := register-referentie.slnx COMPOSE := infra/docker-compose.yml -HEALTH_URL := http://localhost:8080/health +# Long-running services with a healthcheck — the smoke polls these for readiness +# (infra/wait-healthy.sh). One-shot init jobs (oz-init, nrc-init, flowable-init) +# are not polled; they only need to have run. See docs/runbooks/gitea-actions-gotchas.md. +WAIT_SVCS := openzaak nrc-web acl bff +# Config files (OpenZaak data.yaml, Keycloak realms, Flowable BPMN) are streamed +# into external named volumes via `docker cp` (infra/seed-config.sh) instead of +# bind-mounted, because bind mounts don't reach sibling containers on the +# containerized CI runner. SEED populates them; run it before every `up`. The +# volumes are `external`, so compose won't remove them — CFG_VOLS lists them for +# explicit teardown. See docs/runbooks/gitea-actions-gotchas.md. +SEED := bash infra/seed-config.sh +CFG_VOLS := rr-oz-config rr-kc-realms rr-fl-bpmn +# Local-only stack: same services but config is bind-mounted (no seed step), so a +# plain `docker compose -f infra/docker-compose.local.yml up` works on any local +# engine. This is the no-make / Windows-friendly path. See that file's header. +LOCAL_COMPOSE := infra/docker-compose.local.yml OZ_COMPOSE := infra/openzaak/docker-compose.yml OZ_BASE := http://localhost:8000 NRC_COMPOSE := infra/opennotificaties/docker-compose.yml @@ -28,7 +43,7 @@ export DOCKER_HOST := unix://$(PODMAN_SOCK) endif endif -.PHONY: ci lint build unit smoke down changelog openzaak-up openzaak-smoke openzaak-seed openzaak-down stack-up stack-smoke stack-down keycloak-up keycloak-smoke keycloak-down flowable-up flowable-smoke flowable-down help +.PHONY: ci lint build unit smoke up down local local-down changelog openzaak-up openzaak-smoke openzaak-seed openzaak-down stack-up stack-smoke stack-down keycloak-up keycloak-smoke keycloak-down flowable-up flowable-smoke flowable-down help ## ci: run the full pipeline — lint, build, unit, smoke (mirrors Gitea Actions) ci: lint build unit smoke @@ -45,14 +60,38 @@ build: unit: dotnet test $(SLN) -c Release -## smoke: compose up (wait for healthy), curl /health, then tear down +## smoke: seed config, bring the whole stack up, wait for health-checked services, tear down +# SEED populates the external config volumes first (upstream images used verbatim; +# only our acl/bff are built). `up -d --build` starts EVERYTHING. Readiness is +# checked by infra/wait-healthy.sh polling the durable, health-checked services +# ($(WAIT_SVCS)) via `docker inspect` — portable across docker compose and +# podman-compose, and needing no `--wait` flag or host port access. The one-shots +# (oz-init, flowable-init) aren't polled; they just need to have run. smoke: - docker compose -f $(COMPOSE) up -d --build --wait - bash -c 'curl -fsS $(HEALTH_URL); rc=$$?; docker compose -f $(COMPOSE) down --volumes; exit $$rc' + $(SEED) oz kc fl + docker compose -f $(COMPOSE) up -d --build + bash -c 'WAIT_TIMEOUT=420 bash infra/wait-healthy.sh $(WAIT_SVCS); rc=$$?; docker compose -f $(COMPOSE) down --volumes; docker volume rm -f $(CFG_VOLS) >/dev/null 2>&1; exit $$rc' -## down: stop and remove the local stack +## up: seed config volumes and start the full stack (use instead of bare +## `docker compose up`, which can't self-seed the external config volumes) +up: + $(SEED) oz kc fl + docker compose -f $(COMPOSE) up -d --build + +## down: stop and remove the local stack (incl. the external config volumes) down: docker compose -f $(COMPOSE) down --volumes + -docker volume rm -f $(CFG_VOLS) + +## local: bring up the bind-mount stack (no seed step) and wait for health +## (Windows / no-make users: run `docker compose -f infra/docker-compose.local.yml up -d --build` directly) +local: + docker compose -f $(LOCAL_COMPOSE) up -d --build + WAIT_TIMEOUT=420 bash infra/wait-healthy.sh $(WAIT_SVCS) + +## local-down: stop and remove the bind-mount stack +local-down: + docker compose -f $(LOCAL_COMPOSE) down --volumes ## changelog: regenerate CHANGELOG.md from Conventional Commits (git-cliff) changelog: @@ -60,11 +99,11 @@ changelog: ## openzaak-up: start the OpenZaak stack (migrations run on first start) openzaak-up: + $(SEED) oz docker compose -f $(OZ_COMPOSE) up -d ## openzaak-smoke: start OpenZaak, then assert it is up with auth enforced -openzaak-smoke: - docker compose -f $(OZ_COMPOSE) up -d +openzaak-smoke: openzaak-up @bash -c 'set -e; \ echo "waiting for OpenZaak to respond..."; \ for i in $$(seq 1 60); do \ @@ -88,9 +127,11 @@ openzaak-seed: openzaak-up ## openzaak-down: stop and remove the OpenZaak stack (wipes data) openzaak-down: docker compose -f $(OZ_COMPOSE) down --volumes + -docker volume rm -f rr-oz-config ## stack-up: start OpenZaak + Open Notificaties together (shared network) stack-up: + $(SEED) oz docker compose $(STACK_FILES) up -d ## stack-smoke: start both, assert OpenZaak (403/302/200) and NRC (302) are reachable @@ -110,9 +151,11 @@ stack-smoke: stack-up ## stack-down: stop and remove both stacks (wipes data) stack-down: docker compose $(STACK_FILES) down --volumes + -docker volume rm -f rr-oz-config ## keycloak-up: start Keycloak with the four imported realms keycloak-up: + $(SEED) kc docker compose -f $(KC_COMPOSE) up -d ## keycloak-smoke: start Keycloak, then verify each realm logs in + returns its claim @@ -125,9 +168,11 @@ keycloak-smoke: keycloak-up ## keycloak-down: stop and remove Keycloak keycloak-down: docker compose -f $(KC_COMPOSE) down --volumes + -docker volume rm -f rr-kc-realms ## flowable-up: start Flowable (deploys registratie.bpmn on boot) flowable-up: + $(SEED) fl docker compose -f $(FL_COMPOSE) up -d ## flowable-smoke: start Flowable, then verify a started instance waits on the external task @@ -140,6 +185,7 @@ flowable-smoke: flowable-up ## flowable-down: stop and remove Flowable flowable-down: docker compose -f $(FL_COMPOSE) down --volumes + -docker volume rm -f rr-fl-bpmn ## help: list available targets help: diff --git a/docs/runbooks/ci.md b/docs/runbooks/ci.md index 4e84e5d..704a6c8 100644 --- a/docs/runbooks/ci.md +++ b/docs/runbooks/ci.md @@ -1,11 +1,9 @@ # CI runbook — Gitea Actions -> **Status: no runner yet → run CI locally with `make ci`.** The workflow -> `.gitea/workflows/ci.yaml` is in place, but the pipeline cannot go green until a -> self-hosted `respellion-linux` runner is registered against the Gitea instance. -> Until then, **`make ci` is the gate** — it runs the exact same checks locally -> (the workflow calls the same `make` targets). Issue **#30 (S-00-c)** stays open -> until CI is verified green on a runner. +> **Status: active.** The workflow `.gitea/workflows/ci.yaml` runs on Gitea's +> hosted `ubuntu-latest` runner — no self-hosted runner required. +> **`make ci` is still the local gate** — it runs the exact same checks +> (the workflow calls the same `make` targets). ## The pipeline @@ -18,12 +16,40 @@ and CI cannot drift: | `lint` | `make lint` → `dotnet format … --verify-no-changes` | .NET 10 SDK | | `build` | `make build` → `dotnet build … -c Release` | .NET 10 SDK | | `unit` | `make unit` → `dotnet test … -c Release` | .NET 10 SDK | -| `compose-smoke` | `make smoke` → compose up `--wait` → `curl /health` → `down` | container engine + compose v2 | +| `compose-smoke` | `make smoke` → seed config volumes → `up -d` (full stack) → `up --wait` durable services → `down` | container engine + compose v2 | All `uses:` references are absolute, tag-pinned URLs (`https://github.com/actions/checkout@v4`, `https://github.com/actions/setup-dotnet@v4`) per CLAUDE.md §8.7 and §15 — Gitea Actions resolves them from GitHub. +> **`compose-smoke` runs on a containerized runner.** Workspace bind mounts do +> **not** reach the sibling containers Compose starts, so config/assets are +> streamed into external named volumes via `docker cp` (`infra/seed-config.sh`), +> and the upstream images are used verbatim (no build). If you add a service that +> needs a repo file at runtime, seed it the same way — don't bind-mount it. Note: +> bare `docker compose up` no longer self-seeds; use `make up`. See +> [gitea-actions-gotchas.md](gitea-actions-gotchas.md). + +## Running the stack locally without `make` (Windows / Docker Desktop) + +`make` and the bash helpers assume a Unix shell. To bring the whole stack up on a +machine without them (e.g. Windows + Docker Desktop), use the **local compose +file**, which bind-mounts the config instead of seeding volumes — so it needs no +`make`, no seed step, and no bash: + +```bash +docker compose -f infra/docker-compose.local.yml up -d --build # any engine +docker compose -f infra/docker-compose.local.yml up -d --build --wait # Docker Desktop (Compose v2) +docker compose -f infra/docker-compose.local.yml down --volumes +``` + +On Linux/macOS the same thing is wrapped as `make local` / `make local-down`. + +`infra/docker-compose.local.yml` mirrors the canonical `infra/docker-compose.yml` +but swaps the external config volumes for bind mounts — valid locally because a +local daemon can see the working directory (the seed/volume dance only exists for +the containerized CI runner). Keep the two files in sync. + ## Running CI locally (`make ci`) Until the runner exists, run the full pipeline yourself before pushing: @@ -49,56 +75,26 @@ The Makefile auto-points `DOCKER_HOST` at `/run/user/$(id -u)/podman/podman.sock when that socket exists and `DOCKER_HOST` is unset, so `make smoke` "just works" locally while leaving real Docker hosts / CI runners untouched. -## Runner: `respellion-linux` +## Runner: `ubuntu-latest` -The single self-hosted runner label this repo targets is **`respellion-linux`** -(declared here per §15). It is intended to run **co-located on the Gitea server** -(`git.labs.respellion.tech` / `46.224.220.37`) so CI is durable and independent of -any developer machine. +All jobs run on Gitea's hosted **`ubuntu-latest`** runner — no self-hosted runner +setup is required. The hosted runner ships with Docker and Docker Compose v2, so +`make smoke` (`docker compose … up --wait`) works without extra configuration. -### Host prerequisites - -The runner executes jobs in **host mode** (see registration below), so the host -must have, on `PATH`: - -- .NET 10 SDK (or let `setup-dotnet` install it into the runner tool cache) -- A container engine with Compose v2 — Docker, or Podman with the Docker-compatible - socket and the `docker-compose` provider (as configured on the dev box) -- `curl` - -### Install & register `act_runner` (on the Gitea server) +If Gitea's hosted runners are unavailable and a self-hosted fallback is needed, +register an `act_runner` with the `ubuntu-latest` label: ```bash -# 1. Install the binary (pick the version matching the Gitea release line) VER=0.2.11 curl -fsSL -o /usr/local/bin/act_runner \ "https://dl.gitea.com/act_runner/${VER}/act_runner-${VER}-linux-amd64" chmod +x /usr/local/bin/act_runner -# 2. Obtain a registration token from the Gitea UI: -# Site Administration → Actions → Runners → "Create new Runner" (instance-level) -# (or Repo → Settings → Actions → Runners for a repo-scoped runner) - -# 3. Register with the respellion-linux label in HOST execution mode. -# The ":host" suffix means jobs run directly on the host shell, so -# `docker compose` in compose-smoke uses the host engine (no docker-in-docker). act_runner register --no-interactive \ --instance https://git.labs.respellion.tech \ --token \ --name respellion-ci-1 \ - --labels "respellion-linux:host" + --labels "ubuntu-latest:docker://node:20-bookworm" -# 4. Run it (foreground to verify, then install as a systemd service) act_runner daemon ``` - -Verify in the Gitea UI (Actions → Runners) that `respellion-ci-1` shows **Idle**, -then re-run the `CI` workflow; all four jobs should pass. - -## Security note - -A self-hosted runner in **host mode** executes workflow code directly on the Gitea -server host. Anyone who can push a workflow can run code there. This is acceptable -for a **private lab** instance with trusted contributors. For anything -internet-facing, switch to container/VM isolation (`--labels "respellion-linux:docker://..."`) -or a dedicated runner host, and gate workflow runs on approval for outside PRs. diff --git a/docs/runbooks/gitea-actions-gotchas.md b/docs/runbooks/gitea-actions-gotchas.md new file mode 100644 index 0000000..52da86d --- /dev/null +++ b/docs/runbooks/gitea-actions-gotchas.md @@ -0,0 +1,100 @@ +# Gitea Actions gotchas + +How our CI (Gitea Actions on the hosted **`ubuntu-latest`** runner) differs from a +local run, and the workarounds in this repo. Referenced by `CLAUDE.md` §8.7/§15. + +**One root cause sits under most of this:** the runner executes the job **inside a +container**, so when a step runs `docker compose up`, Compose starts the stack as +**sibling containers** on the host's daemon. Anything that assumes the job and +those containers share a filesystem — or a `localhost` — breaks. + +| Gotcha | Fix | Lives in | +|---|---|---| +| Bind-mounted config arrives empty | `docker cp` config into external volumes | `infra/seed-config.sh` | +| `docker compose up --wait` is unsupported / flaky | poll health with `docker inspect` | `infra/wait-healthy.sh` | +| `pg_isready` passes before PostGIS is ready | add a `PostGIS_Version()` probe | the db healthchecks | + +--- + +## 1. Bind mounts don't reach the containers + +**Symptom** — green locally, but `compose-smoke` fails with: + +``` +oz-init-1 | CommandError: Yaml file `/app/setup_configuration/data.yaml` does not exist. +``` + +Migrations run fine; only the step that reads a *mounted* file fails. The same +trap hits `nrc-init`, `flowable-init`, and `keycloak`. + +**Why** — a relative bind mount like `./openzaak/setup_configuration:/app/...` is +resolved by Compose to a path *inside the job container* +(`/workspace/.../setup_configuration`). The daemon then looks for that path on +*its own host*, doesn't find it, and mounts an **empty directory**. (It works on a +runner that executes jobs on the host — which is why moving to `ubuntu-latest` +exposed it.) + +**Fix** — use the upstream images verbatim (no build) and stream config into +**external named volumes** with `docker cp`, which copies over the Docker API and +so works wherever the daemon runs. `infra/seed-config.sh` creates each volume, +mounts it in a throwaway helper, and copies the files in: + +| Asset | Volume | Mounted at | +|---|---|---| +| OpenZaak `data.yaml` | `rr-oz-config` | `oz-init:/app/setup_configuration` | +| Keycloak realms | `rr-kc-realms` | `keycloak:/opt/keycloak/data/import` | +| `registratie.bpmn` | `rr-fl-bpmn` | `flowable-init:/work` | + +The volumes are `external: true` with fixed names, so they resolve identically +under docker compose and podman-compose. `make` seeds before every `up`; `make +down` removes them. (Open Notificaties needs nothing — `nrc-init` migrates only.) + +**Consequence — bare `docker compose up` can't self-seed external volumes:** + +- **CI / Linux / macOS:** `make up` or `make smoke` (seed, then start). +- **No-make / Windows:** `infra/docker-compose.local.yml` — a twin stack that + **bind-mounts** the config instead. Bind mounts are fine *locally* because a + local daemon can see your working directory, so + `docker compose -f infra/docker-compose.local.yml up -d` just works. + +**Why not the obvious alternatives** + +- *Bake config into an image* (incl. an inline Dockerfile) — `docker compose up` + would then work unaided, but it's a build; we wanted the upstream images as-is. +- *Compose `configs:` with inline `content`* — Compose writes a client-side temp + file and bind-mounts it, hitting the exact same problem. +- *A host-executing runner* — bind mounts would work with zero seeding, but it + reintroduces a self-hosted runner and undoes the move to `ubuntu-latest`. + +--- + +## 2. Readiness: poll health, don't use `--wait` + +`docker compose up --wait` looks ideal but fails us three ways: + +- **podman-compose doesn't implement it** (`unrecognized arguments: --wait`) — so + it would break local dev. +- A project-wide `--wait` **treats a one-shot exiting `0` as a failure** unless + something `depends_on` it with `service_completed_successfully`. `flowable-init` + deploys the BPMN and exits with no dependant, so `--wait` fails the moment it + does — last line `container infra-flowable-init-1 exited (0)`. +- The containerized runner **can't reach published host ports**, so an external + `curl localhost:8080/health` can't work either. + +**Fix** — `infra/wait-healthy.sh` polls each durable service (`openzaak nrc-web +acl bff`, listed as `WAIT_SVCS` in the `Makefile`) with `docker ps` + `docker +inspect '{{.State.Health.Status}}'` until it reports `healthy`. It uses only +primitives both runtimes support, reads the **in-container** healthcheck (no host +port needed), and ignores the one-shots (they only need to have run). +`WAIT_TIMEOUT` defaults to 420 s — enough for the cold OpenZaak migrate (~90 s) +plus app start. + +--- + +## 3. `pg_isready` passes before PostGIS is ready + +`pg_isready` succeeds as soon as the TCP port is open — *before* the +`postgis/postgis` image has finished running `CREATE EXTENSION postgis`. An init +container that starts migrating in that window can fail on a missing PostGIS. So +the db healthchecks add a `SELECT PostGIS_Version()` probe, making dependents wait +for the extension, not just the port. diff --git a/docs/runbooks/openzaak.md b/docs/runbooks/openzaak.md index 107a141..b054416 100644 --- a/docs/runbooks/openzaak.md +++ b/docs/runbooks/openzaak.md @@ -71,5 +71,12 @@ The Makefile auto-points `DOCKER_HOST` at the Podman socket when it exists, so t but OZ→NRC delivery wiring + re-enabling lands with **S-06**. - **Zaaktype is a concept**, not published (publishing needs roltypen/statustypen/ resultaattypen — beyond the lean seed). List with `?status=alles`. -- **Image tag.** Currently `openzaak/open-zaak:latest` via `${OPENZAAK_TAG}`; pin to - a known-good tag (ADR-0002 follow-up). +- **Image tag.** Pinned to `openzaak/open-zaak:1.28.2` via `${OPENZAAK_TAG}` (bump + deliberately, not via `:latest`). +- **Config arrives via a volume, not a bind mount.** `setup_configuration/data.yaml` + is streamed into the external `rr-oz-config` volume by `infra/seed-config.sh` + (`docker cp`) and mounted at `/app/setup_configuration`, so the init container + finds it on Gitea's containerized CI runner too (bind mounts don't reach sibling + containers there). The image is the upstream `openzaak/open-zaak` verbatim — no + build. Run via `make openzaak-up` (seeds first). See + [gitea-actions-gotchas.md](gitea-actions-gotchas.md). diff --git a/infra/docker-compose.local.yml b/infra/docker-compose.local.yml new file mode 100644 index 0000000..691ec77 --- /dev/null +++ b/infra/docker-compose.local.yml @@ -0,0 +1,296 @@ +# LOCAL development stack — runs with a plain `docker compose up`, no make / no +# seed step / no bash. Use this on a local engine (Docker Desktop on Windows or +# macOS, or rootless Podman on Linux). +# +# docker compose -f infra/docker-compose.local.yml up -d --build # podman +# docker compose -f infra/docker-compose.local.yml up -d --build --wait # Docker Desktop +# docker compose -f infra/docker-compose.local.yml down --volumes +# +# It is identical to infra/docker-compose.yml EXCEPT that the three config inputs +# (OpenZaak data.yaml, Keycloak realms, Flowable BPMN) are **bind-mounted** from +# the repo instead of being streamed into external volumes by infra/seed-config.sh. +# Bind mounts work here because a local daemon can see your working directory — +# the seed dance only exists for the containerized CI runner, where it can't. See +# docs/runbooks/gitea-actions-gotchas.md. +# +# `infra/docker-compose.yml` remains the CI-canonical stack; keep the two in sync. +# +# Port map (host): +# 8000 OpenZaak · 8001 Open Notificaties · 8080 BFF · 8090 Flowable REST +# 8100 ACL · 8180 Keycloak (all admin: admin / admin — dev only) + +services: + + # ── OpenZaak (S-01) ────────────────────────────────────────────────────── + oz-db: + image: docker.io/postgis/postgis:17-3.5 + environment: + POSTGRES_USER: openzaak + POSTGRES_PASSWORD: openzaak + POSTGRES_DB: openzaak + command: postgres -c max_connections=300 + volumes: + - oz-db:/var/lib/postgresql/data + healthcheck: + test: ["CMD-SHELL", "pg_isready -U openzaak -d openzaak && psql -U openzaak -d openzaak -c 'SELECT PostGIS_Version();' -q 2>/dev/null"] + interval: 5s + timeout: 5s + retries: 30 + start_period: 15s + networks: [cg] + + oz-redis: + image: docker.io/library/redis:7 + networks: [cg] + + oz-init: + image: docker.io/openzaak/open-zaak:${OPENZAAK_TAG:-1.28.2} + environment: &oz-env + DJANGO_SETTINGS_MODULE: openzaak.conf.docker + SECRET_KEY: ${OZ_SECRET_KEY:-dev-only-not-for-production} + DB_HOST: oz-db + DB_NAME: openzaak + DB_USER: openzaak + DB_PASSWORD: openzaak + IS_HTTPS: "no" + ALLOWED_HOSTS: "*" + CACHE_DEFAULT: oz-redis:6379/0 + CACHE_AXES: oz-redis:6379/0 + CELERY_BROKER_URL: redis://oz-redis:6379/1 + CELERY_RESULT_BACKEND: redis://oz-redis:6379/1 + DISABLE_2FA: "true" + NOTIFICATIONS_DISABLED: "true" + OPENZAAK_SUPERUSER_USERNAME: admin + DJANGO_SUPERUSER_PASSWORD: admin + OPENZAAK_SUPERUSER_EMAIL: admin@localhost + RUN_SETUP_CONFIG: "true" + command: /setup_configuration.sh + # Bind mount (`:z` relabels for SELinux on Linux; a no-op on Docker Desktop). + volumes: + - ./openzaak/setup_configuration:/app/setup_configuration:ro,z + depends_on: + oz-db: + condition: service_healthy + oz-redis: + condition: service_started + networks: [cg] + + openzaak: + image: docker.io/openzaak/open-zaak:${OPENZAAK_TAG:-1.28.2} + environment: *oz-env + healthcheck: + test: ["CMD", "python", "-c", "import requests,sys; sys.exit(0 if requests.head('http://localhost:8000/admin/').status_code in (200,302) else 1)"] + interval: 10s + timeout: 5s + retries: 10 + start_period: 30s + ports: + - "8000:8000" + depends_on: + oz-init: + condition: service_completed_successfully + networks: [cg] + + oz-celery: + image: docker.io/openzaak/open-zaak:${OPENZAAK_TAG:-1.28.2} + environment: *oz-env + command: /celery_worker.sh + depends_on: + oz-init: + condition: service_completed_successfully + networks: [cg] + + # ── Open Notificaties / NRC (S-01-c) ───────────────────────────────────── + nrc-db: + image: docker.io/postgis/postgis:17-3.5 + environment: + POSTGRES_USER: opennotificaties + POSTGRES_PASSWORD: opennotificaties + POSTGRES_DB: opennotificaties + command: postgres -c max_connections=300 + volumes: + - nrc-db:/var/lib/postgresql/data + healthcheck: + test: ["CMD-SHELL", "pg_isready -U opennotificaties -d opennotificaties"] + interval: 5s + timeout: 3s + retries: 10 + networks: [cg] + + nrc-redis: + image: docker.io/library/redis:7 + networks: [cg] + + nrc-init: + # Migrations only (see the canonical compose / ADR-0002); no config needed. + image: docker.io/openzaak/open-notificaties:${OPENNOTIFICATIES_TAG:-1.16.1} + environment: &nrc-env + DJANGO_SETTINGS_MODULE: nrc.conf.docker + SECRET_KEY: ${NRC_SECRET_KEY:-dev-only-not-for-production} + DB_HOST: nrc-db + DB_NAME: opennotificaties + DB_USER: opennotificaties + DB_PASSWORD: opennotificaties + IS_HTTPS: "no" + ALLOWED_HOSTS: "*" + CACHE_DEFAULT: nrc-redis:6379/0 + CACHE_AXES: nrc-redis:6379/0 + CELERY_BROKER_URL: redis://nrc-redis:6379/1 + CELERY_RESULT_BACKEND: redis://nrc-redis:6379/1 + DISABLE_2FA: "true" + OPENNOTIFICATIES_SUPERUSER_USERNAME: admin + DJANGO_SUPERUSER_PASSWORD: admin + OPENNOTIFICATIES_SUPERUSER_EMAIL: admin@localhost + command: ["sh", "-c", "/wait_for_db.sh && OTEL_SDK_DISABLED=True python src/manage.py migrate"] + depends_on: + nrc-db: + condition: service_healthy + nrc-redis: + condition: service_started + openzaak: + condition: service_healthy + networks: [cg] + + nrc-web: + image: docker.io/openzaak/open-notificaties:${OPENNOTIFICATIES_TAG:-1.16.1} + environment: *nrc-env + healthcheck: + test: ["CMD", "python", "-c", "import requests,sys; sys.exit(0 if requests.head('http://localhost:8000/admin/').status_code in (200,302) else 1)"] + interval: 10s + timeout: 5s + retries: 10 + start_period: 30s + ports: + - "8001:8000" + depends_on: + nrc-init: + condition: service_completed_successfully + networks: [cg] + + nrc-celery: + image: docker.io/openzaak/open-notificaties:${OPENNOTIFICATIES_TAG:-1.16.1} + environment: *nrc-env + command: /celery_worker.sh + depends_on: + nrc-init: + condition: service_completed_successfully + networks: [cg] + + # ── Keycloak (S-02) ────────────────────────────────────────────────────── + keycloak: + image: quay.io/keycloak/keycloak:26.1 + command: ["start-dev", "--import-realm"] + environment: + KC_BOOTSTRAP_ADMIN_USERNAME: admin + KC_BOOTSTRAP_ADMIN_PASSWORD: admin + KEYCLOAK_ADMIN: admin + KEYCLOAK_ADMIN_PASSWORD: admin + KC_HEALTH_ENABLED: "true" + KC_HTTP_ENABLED: "true" + ports: + - "8180:8080" + volumes: + - ./keycloak/realms:/opt/keycloak/data/import:ro,z + networks: [cg] + + # ── Flowable (S-03) ────────────────────────────────────────────────────── + flowable-db: + image: docker.io/library/postgres:16 + environment: + POSTGRES_USER: flowable + POSTGRES_PASSWORD: flowable + POSTGRES_DB: flowable + volumes: + - flowable-db:/var/lib/postgresql/data + healthcheck: + test: ["CMD-SHELL", "pg_isready -U flowable -d flowable"] + interval: 5s + timeout: 3s + retries: 10 + networks: [cg] + + flowable-rest: + image: docker.io/flowable/flowable-rest:latest + environment: + SPRING_DATASOURCE_DRIVER-CLASS-NAME: org.postgresql.Driver + SPRING_DATASOURCE_URL: jdbc:postgresql://flowable-db:5432/flowable + SPRING_DATASOURCE_USERNAME: flowable + SPRING_DATASOURCE_PASSWORD: flowable + ports: + - "8090:8080" + depends_on: + flowable-db: + condition: service_healthy + networks: [cg] + + flowable-init: + image: docker.io/curlimages/curl:latest + restart: "no" + volumes: + - ../workflows/registratie.bpmn:/work/registratie.bpmn:ro,z + command: + - sh + - -c + - | + base=http://flowable-rest:8080/flowable-rest/service/repository/deployments + until curl -sf -u rest-admin:test "$$base" >/dev/null 2>&1; do echo "waiting for flowable-rest..."; sleep 3; done + if curl -s -u rest-admin:test "$$base?name=registratie" | grep -q '"name":"registratie"'; then + echo "registratie already deployed; skip" + else + curl -sf -u rest-admin:test -F 'file=@/work/registratie.bpmn;filename=registratie.bpmn' "$$base" >/dev/null && echo "deployed registratie" + fi + depends_on: + flowable-rest: + condition: service_started + networks: [cg] + + # ── ACL ────────────────────────────────────────────────────────────────── + acl: + build: + context: ../services/acl + dockerfile: Dockerfile + image: register-referentie/acl:dev + environment: + Acl__OpenZaak__BaseUrl: http://openzaak:8000/ + Acl__OpenZaak__ClientId: big-reference-seed + Acl__OpenZaak__Secret: insecure-dev-secret-change-me + Acl__Defaults__Bronorganisatie: "517439943" + Acl__Defaults__VerantwoordelijkeOrganisatie: "517439943" + Acl__Defaults__Vertrouwelijkheidaanduiding: openbaar + Acl__Defaults__ZaaktypeUrl: ${ACL_ZAAKTYPE_URL:-http://openzaak:8000/catalogi/api/v1/zaaktypen/00000000-0000-0000-0000-000000000000} + ports: + - "8100:8080" + healthcheck: + test: ["CMD", "curl", "-fsS", "http://localhost:8080/health"] + interval: 5s + timeout: 3s + retries: 5 + start_period: 10s + depends_on: + openzaak: + condition: service_healthy + networks: [cg] + + # ── BFF ────────────────────────────────────────────────────────────────── + bff: + build: + context: ../services/bff + dockerfile: Dockerfile + image: register-referentie/bff:dev + ports: + - "8080:8080" + healthcheck: + test: ["CMD", "curl", "-fsS", "http://localhost:8080/health"] + interval: 5s + timeout: 3s + retries: 5 + start_period: 10s + networks: [cg] + +volumes: + oz-db: + nrc-db: + flowable-db: + +networks: + cg: diff --git a/infra/docker-compose.yml b/infra/docker-compose.yml index 1c5e980..b138c6a 100644 --- a/infra/docker-compose.yml +++ b/infra/docker-compose.yml @@ -1,9 +1,289 @@ -# Local development stack. Grows service-by-service with each slice. -# S-00-b: the placeholder BFF with a /health check. +# Development stack — boots all infra services plus the ACL and BFF. +# +# Consolidates infra/openzaak/, infra/opennotificaties/, infra/keycloak/, +# and infra/flowable/ and adds the ACL and BFF services. +# +# Port map (host): +# 8000 OpenZaak ZGW API (admin: admin / admin) +# 8001 Open Notificaties (admin: admin / admin) +# 8080 BFF GET /health → Healthy +# 8090 Flowable REST http://localhost:8090/flowable-rest/service/ +# 8100 ACL GET /health → Healthy POST /zaken +# 8180 Keycloak (admin: admin / admin) # # docker compose -f infra/docker-compose.yml up -d --build --wait -# curl http://localhost:8080/health # -> Healthy +# +# After first boot, seed the BIG catalogus and note the zaaktype URL: +# python infra/openzaak/seed_catalogus.py +# Then set ACL_ZAAKTYPE_URL in a .env file or your shell and re-up the acl +# service: +# export ACL_ZAAKTYPE_URL=http://openzaak:8000/catalogi/api/v1/zaaktypen/ +# docker compose -f infra/docker-compose.yml up -d acl + services: + + # ── OpenZaak (S-01) ────────────────────────────────────────────────────── + oz-db: + image: docker.io/postgis/postgis:17-3.5 + environment: + POSTGRES_USER: openzaak + POSTGRES_PASSWORD: openzaak + POSTGRES_DB: openzaak + command: postgres -c max_connections=300 + volumes: + - oz-db:/var/lib/postgresql/data + healthcheck: + # pg_isready only checks TCP; the second clause verifies PostGIS is installed + # so oz-init migrations can safely start (avoids race on cold container start). + test: ["CMD-SHELL", "pg_isready -U openzaak -d openzaak && psql -U openzaak -d openzaak -c 'SELECT PostGIS_Version();' -q 2>/dev/null"] + interval: 5s + timeout: 5s + retries: 30 + start_period: 15s + networks: [cg] + + oz-redis: + image: docker.io/library/redis:7 + networks: [cg] + + oz-init: + image: docker.io/openzaak/open-zaak:${OPENZAAK_TAG:-1.28.2} + environment: &oz-env + DJANGO_SETTINGS_MODULE: openzaak.conf.docker + SECRET_KEY: ${OZ_SECRET_KEY:-dev-only-not-for-production} + DB_HOST: oz-db + DB_NAME: openzaak + DB_USER: openzaak + DB_PASSWORD: openzaak + IS_HTTPS: "no" + ALLOWED_HOSTS: "*" + CACHE_DEFAULT: oz-redis:6379/0 + CACHE_AXES: oz-redis:6379/0 + CELERY_BROKER_URL: redis://oz-redis:6379/1 + CELERY_RESULT_BACKEND: redis://oz-redis:6379/1 + DISABLE_2FA: "true" + NOTIFICATIONS_DISABLED: "true" + OPENZAAK_SUPERUSER_USERNAME: admin + DJANGO_SUPERUSER_PASSWORD: admin + OPENZAAK_SUPERUSER_EMAIL: admin@localhost + RUN_SETUP_CONFIG: "true" + command: /setup_configuration.sh + # data.yaml is streamed into this external volume by infra/seed-config.sh + # before start (bind mounts don't reach sibling containers on the CI runner). + volumes: + - oz-config:/app/setup_configuration:ro + depends_on: + oz-db: + condition: service_healthy + oz-redis: + condition: service_started + networks: [cg] + + openzaak: + image: docker.io/openzaak/open-zaak:${OPENZAAK_TAG:-1.28.2} + environment: *oz-env + healthcheck: + test: ["CMD", "python", "-c", "import requests,sys; sys.exit(0 if requests.head('http://localhost:8000/admin/').status_code in (200,302) else 1)"] + interval: 10s + timeout: 5s + retries: 10 + start_period: 30s + ports: + - "8000:8000" + depends_on: + oz-init: + condition: service_completed_successfully + networks: [cg] + + oz-celery: + image: docker.io/openzaak/open-zaak:${OPENZAAK_TAG:-1.28.2} + environment: *oz-env + command: /celery_worker.sh + depends_on: + oz-init: + condition: service_completed_successfully + networks: [cg] + + # ── Open Notificaties / NRC (S-01-c) ───────────────────────────────────── + nrc-db: + image: docker.io/postgis/postgis:17-3.5 + environment: + POSTGRES_USER: opennotificaties + POSTGRES_PASSWORD: opennotificaties + POSTGRES_DB: opennotificaties + command: postgres -c max_connections=300 + volumes: + - nrc-db:/var/lib/postgresql/data + healthcheck: + test: ["CMD-SHELL", "pg_isready -U opennotificaties -d opennotificaties"] + interval: 5s + timeout: 3s + retries: 10 + networks: [cg] + + nrc-redis: + image: docker.io/library/redis:7 + networks: [cg] + + nrc-init: + # Plain base image — nrc-init runs migrations only (see command below), so it + # needs no baked config. + image: docker.io/openzaak/open-notificaties:${OPENNOTIFICATIES_TAG:-1.16.1} + environment: &nrc-env + DJANGO_SETTINGS_MODULE: nrc.conf.docker + SECRET_KEY: ${NRC_SECRET_KEY:-dev-only-not-for-production} + DB_HOST: nrc-db + DB_NAME: opennotificaties + DB_USER: opennotificaties + DB_PASSWORD: opennotificaties + IS_HTTPS: "no" + ALLOWED_HOSTS: "*" + CACHE_DEFAULT: nrc-redis:6379/0 + CACHE_AXES: nrc-redis:6379/0 + CELERY_BROKER_URL: redis://nrc-redis:6379/1 + CELERY_RESULT_BACKEND: redis://nrc-redis:6379/1 + DISABLE_2FA: "true" + OPENNOTIFICATIES_SUPERUSER_USERNAME: admin + DJANGO_SUPERUSER_PASSWORD: admin + OPENNOTIFICATIES_SUPERUSER_EMAIL: admin@localhost + # Migrations only for now. No setup_configuration steps are enabled yet (the + # OZ<->NRC notification wiring lands in S-06), and NRC's `setup_configuration` + # aborts with "No steps enabled" on the empty data.yaml — so we run `migrate` + # directly instead of /setup_configuration.sh. See data.yaml and ADR-0002. + command: ["sh", "-c", "/wait_for_db.sh && OTEL_SDK_DISABLED=True python src/manage.py migrate"] + depends_on: + nrc-db: + condition: service_healthy + nrc-redis: + condition: service_started + openzaak: + condition: service_healthy + networks: [cg] + + nrc-web: + image: docker.io/openzaak/open-notificaties:${OPENNOTIFICATIES_TAG:-1.16.1} + environment: *nrc-env + healthcheck: + test: ["CMD", "python", "-c", "import requests,sys; sys.exit(0 if requests.head('http://localhost:8000/admin/').status_code in (200,302) else 1)"] + interval: 10s + timeout: 5s + retries: 10 + start_period: 30s + ports: + - "8001:8000" + depends_on: + nrc-init: + condition: service_completed_successfully + networks: [cg] + + nrc-celery: + image: docker.io/openzaak/open-notificaties:${OPENNOTIFICATIES_TAG:-1.16.1} + environment: *nrc-env + command: /celery_worker.sh + depends_on: + nrc-init: + condition: service_completed_successfully + networks: [cg] + + # ── Keycloak (S-02) ────────────────────────────────────────────────────── + keycloak: + image: quay.io/keycloak/keycloak:26.1 + command: ["start-dev", "--import-realm"] + environment: + KC_BOOTSTRAP_ADMIN_USERNAME: admin + KC_BOOTSTRAP_ADMIN_PASSWORD: admin + KEYCLOAK_ADMIN: admin + KEYCLOAK_ADMIN_PASSWORD: admin + KC_HEALTH_ENABLED: "true" + KC_HTTP_ENABLED: "true" + ports: + - "8180:8080" + # realm exports are streamed into this external volume by infra/seed-config.sh. + volumes: + - kc-realms:/opt/keycloak/data/import:ro + networks: [cg] + + # ── Flowable (S-03) ────────────────────────────────────────────────────── + flowable-db: + image: docker.io/library/postgres:16 + environment: + POSTGRES_USER: flowable + POSTGRES_PASSWORD: flowable + POSTGRES_DB: flowable + volumes: + - flowable-db:/var/lib/postgresql/data + healthcheck: + test: ["CMD-SHELL", "pg_isready -U flowable -d flowable"] + interval: 5s + timeout: 3s + retries: 10 + networks: [cg] + + flowable-rest: + image: docker.io/flowable/flowable-rest:latest + environment: + SPRING_DATASOURCE_DRIVER-CLASS-NAME: org.postgresql.Driver + SPRING_DATASOURCE_URL: jdbc:postgresql://flowable-db:5432/flowable + SPRING_DATASOURCE_USERNAME: flowable + SPRING_DATASOURCE_PASSWORD: flowable + ports: + - "8090:8080" + depends_on: + flowable-db: + condition: service_healthy + networks: [cg] + + flowable-init: + image: docker.io/curlimages/curl:latest + restart: "no" + # registratie.bpmn is streamed into this external volume by infra/seed-config.sh. + volumes: + - fl-bpmn:/work:ro + command: + - sh + - -c + - | + base=http://flowable-rest:8080/flowable-rest/service/repository/deployments + until curl -sf -u rest-admin:test "$$base" >/dev/null 2>&1; do echo "waiting for flowable-rest..."; sleep 3; done + if curl -s -u rest-admin:test "$$base?name=registratie" | grep -q '"name":"registratie"'; then + echo "registratie already deployed; skip" + else + curl -sf -u rest-admin:test -F 'file=@/work/registratie.bpmn;filename=registratie.bpmn' "$$base" >/dev/null && echo "deployed registratie" + fi + depends_on: + flowable-rest: + condition: service_started + networks: [cg] + + # ── ACL ────────────────────────────────────────────────────────────────── + acl: + build: + context: ../services/acl + dockerfile: Dockerfile + image: register-referentie/acl:dev + environment: + Acl__OpenZaak__BaseUrl: http://openzaak:8000/ + Acl__OpenZaak__ClientId: big-reference-seed + Acl__OpenZaak__Secret: insecure-dev-secret-change-me + Acl__Defaults__Bronorganisatie: "517439943" + Acl__Defaults__VerantwoordelijkeOrganisatie: "517439943" + Acl__Defaults__Vertrouwelijkheidaanduiding: openbaar + # Override with the real zaaktype URL after running seed_catalogus.py. + Acl__Defaults__ZaaktypeUrl: ${ACL_ZAAKTYPE_URL:-http://openzaak:8000/catalogi/api/v1/zaaktypen/00000000-0000-0000-0000-000000000000} + ports: + - "8100:8080" + healthcheck: + test: ["CMD", "curl", "-fsS", "http://localhost:8080/health"] + interval: 5s + timeout: 3s + retries: 5 + start_period: 10s + depends_on: + openzaak: + condition: service_healthy + networks: [cg] + + # ── BFF ────────────────────────────────────────────────────────────────── bff: build: context: ../services/bff @@ -17,3 +297,24 @@ services: timeout: 3s retries: 5 start_period: 10s + networks: [cg] + +volumes: + oz-db: + nrc-db: + flowable-db: + # Config volumes — created and populated out-of-band by infra/seed-config.sh + # (docker cp), because bind mounts don't reach sibling containers on the CI + # runner. `external` keeps the names deterministic; the seed step manages them. + oz-config: + external: true + name: rr-oz-config + kc-realms: + external: true + name: rr-kc-realms + fl-bpmn: + external: true + name: rr-fl-bpmn + +networks: + cg: diff --git a/infra/flowable/docker-compose.yml b/infra/flowable/docker-compose.yml index 0aa879a..f1921b6 100644 --- a/infra/flowable/docker-compose.yml +++ b/infra/flowable/docker-compose.yml @@ -40,8 +40,9 @@ services: flowable-init: image: docker.io/curlimages/curl:latest restart: "no" + # registratie.bpmn is streamed into this external volume by infra/seed-config.sh. volumes: - - ../../workflows/registratie.bpmn:/work/registratie.bpmn:ro,z + - fl-bpmn:/work:ro command: - sh - -c @@ -60,6 +61,10 @@ services: volumes: flowable-db: + # populated out-of-band by infra/seed-config.sh (docker cp) — see that script. + fl-bpmn: + external: true + name: rr-fl-bpmn networks: cg: diff --git a/infra/keycloak/docker-compose.yml b/infra/keycloak/docker-compose.yml index b47dcc9..678b553 100644 --- a/infra/keycloak/docker-compose.yml +++ b/infra/keycloak/docker-compose.yml @@ -21,9 +21,15 @@ services: KC_HTTP_ENABLED: "true" ports: - "8180:8080" + # realm exports are streamed into this external volume by infra/seed-config.sh. volumes: - - ./realms:/opt/keycloak/data/import:ro,z + - kc-realms:/opt/keycloak/data/import:ro networks: [cg] +volumes: + kc-realms: + external: true + name: rr-kc-realms + networks: cg: diff --git a/infra/opennotificaties/docker-compose.yml b/infra/opennotificaties/docker-compose.yml index fb08c2a..d333413 100644 --- a/infra/opennotificaties/docker-compose.yml +++ b/infra/opennotificaties/docker-compose.yml @@ -19,10 +19,13 @@ services: volumes: - nrc-db:/var/lib/postgresql/data healthcheck: - test: ["CMD-SHELL", "pg_isready -U opennotificaties -d opennotificaties"] + # pg_isready only checks TCP; the second clause verifies PostGIS is installed + # so nrc-init migrations can safely start (avoids race on cold container start). + test: ["CMD-SHELL", "pg_isready -U opennotificaties -d opennotificaties && psql -U opennotificaties -d opennotificaties -c 'SELECT PostGIS_Version();' -q 2>/dev/null"] interval: 5s - timeout: 3s - retries: 10 + timeout: 5s + retries: 30 + start_period: 15s networks: [cg] nrc-redis: @@ -30,7 +33,8 @@ services: networks: [cg] nrc-init: - image: docker.io/openzaak/open-notificaties:${OPENNOTIFICATIES_TAG:-latest} + # Plain base image — nrc-init runs migrations only (see command below). + image: docker.io/openzaak/open-notificaties:${OPENNOTIFICATIES_TAG:-1.16.1} environment: &nrc-env DJANGO_SETTINGS_MODULE: nrc.conf.docker SECRET_KEY: ${NRC_SECRET_KEY:-dev-only-not-for-production} @@ -48,10 +52,11 @@ services: OPENNOTIFICATIES_SUPERUSER_USERNAME: admin DJANGO_SUPERUSER_PASSWORD: admin OPENNOTIFICATIES_SUPERUSER_EMAIL: admin@localhost - RUN_SETUP_CONFIG: "true" - command: /setup_configuration.sh - volumes: - - ./setup_configuration:/app/setup_configuration:ro,z + # Migrations only for now. No setup_configuration steps are enabled yet (the + # OZ<->NRC notification wiring lands in S-06), and NRC's `setup_configuration` + # aborts with "No steps enabled" on the empty data.yaml — so we run `migrate` + # directly instead of /setup_configuration.sh. See data.yaml and ADR-0002. + command: ["sh", "-c", "/wait_for_db.sh && OTEL_SDK_DISABLED=True python src/manage.py migrate"] depends_on: nrc-db: condition: service_healthy @@ -60,7 +65,7 @@ services: networks: [cg] nrc-web: - image: docker.io/openzaak/open-notificaties:${OPENNOTIFICATIES_TAG:-latest} + image: docker.io/openzaak/open-notificaties:${OPENNOTIFICATIES_TAG:-1.16.1} environment: *nrc-env healthcheck: test: ["CMD", "python", "-c", "import requests,sys; sys.exit(0 if requests.head('http://localhost:8000/admin/').status_code in (200,302) else 1)"] @@ -76,7 +81,7 @@ services: networks: [cg] nrc-celery: - image: docker.io/openzaak/open-notificaties:${OPENNOTIFICATIES_TAG:-latest} + image: docker.io/openzaak/open-notificaties:${OPENNOTIFICATIES_TAG:-1.16.1} environment: *nrc-env command: /celery_worker.sh depends_on: diff --git a/infra/openzaak/docker-compose.yml b/infra/openzaak/docker-compose.yml index c79aba7..9f9e50a 100644 --- a/infra/openzaak/docker-compose.yml +++ b/infra/openzaak/docker-compose.yml @@ -18,10 +18,13 @@ services: volumes: - oz-db:/var/lib/postgresql/data healthcheck: - test: ["CMD-SHELL", "pg_isready -U openzaak -d openzaak"] + # pg_isready only checks TCP; the second clause verifies PostGIS is installed + # so oz-init migrations can safely start (avoids race on cold container start). + test: ["CMD-SHELL", "pg_isready -U openzaak -d openzaak && psql -U openzaak -d openzaak -c 'SELECT PostGIS_Version();' -q 2>/dev/null"] interval: 5s - timeout: 3s - retries: 10 + timeout: 5s + retries: 30 + start_period: 15s networks: [cg] oz-redis: @@ -29,7 +32,7 @@ services: networks: [cg] oz-init: - image: docker.io/openzaak/open-zaak:${OPENZAAK_TAG:-latest} + image: docker.io/openzaak/open-zaak:${OPENZAAK_TAG:-1.28.2} environment: &oz-env DJANGO_SETTINGS_MODULE: openzaak.conf.docker SECRET_KEY: ${OZ_SECRET_KEY:-dev-only-not-for-production} @@ -52,10 +55,9 @@ services: OPENZAAK_SUPERUSER_EMAIL: admin@localhost RUN_SETUP_CONFIG: "true" command: /setup_configuration.sh + # data.yaml is streamed into this external volume by infra/seed-config.sh. volumes: - # :z relabels for SELinux; the dir/file must be world-readable for the - # container user (rootless Podman uid mapping). See docs/runbooks/openzaak.md. - - ./setup_configuration:/app/setup_configuration:ro,z + - oz-config:/app/setup_configuration:ro depends_on: oz-db: condition: service_healthy @@ -64,7 +66,7 @@ services: networks: [cg] openzaak: - image: docker.io/openzaak/open-zaak:${OPENZAAK_TAG:-latest} + image: docker.io/openzaak/open-zaak:${OPENZAAK_TAG:-1.28.2} environment: *oz-env healthcheck: test: ["CMD", "python", "-c", "import requests,sys; sys.exit(0 if requests.head('http://localhost:8000/admin/').status_code in (200,302) else 1)"] @@ -80,7 +82,7 @@ services: networks: [cg] oz-celery: - image: docker.io/openzaak/open-zaak:${OPENZAAK_TAG:-latest} + image: docker.io/openzaak/open-zaak:${OPENZAAK_TAG:-1.28.2} environment: *oz-env command: /celery_worker.sh depends_on: @@ -90,6 +92,10 @@ services: volumes: oz-db: + # populated out-of-band by infra/seed-config.sh (docker cp) — see that script. + oz-config: + external: true + name: rr-oz-config networks: cg: diff --git a/infra/seed-config.sh b/infra/seed-config.sh new file mode 100755 index 0000000..64d2993 --- /dev/null +++ b/infra/seed-config.sh @@ -0,0 +1,45 @@ +#!/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 diff --git a/infra/wait-healthy.sh b/infra/wait-healthy.sh new file mode 100755 index 0000000..a054f70 --- /dev/null +++ b/infra/wait-healthy.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash +# +# Wait until the named compose services report a healthy healthcheck. +# +# Portable across `docker compose` (CI) and `podman-compose` (local dev): it uses +# plain `docker ps` + `docker inspect`, so it needs neither `docker compose +# up --wait` (podman-compose doesn't implement that flag) nor host port access +# (the containerized CI runner can't reach published ports). It also sidesteps the +# `--wait`-fails-when-a-one-shot-exits issue, since we only poll long-running +# services that declare a healthcheck. See docs/runbooks/gitea-actions-gotchas.md. +# +# Usage: WAIT_TIMEOUT=420 wait-healthy.sh [ ...] +set -euo pipefail + +timeout="${WAIT_TIMEOUT:-420}" +deadline=$(( $(date +%s) + timeout )) + +# compose service name -> container id. The name filter matches both docker +# compose ("infra-openzaak-1") and podman-compose ("infra_openzaak_1") naming. +cid_for() { docker ps -aq --filter "name=$1" | head -1; } + +for svc in "$@"; do + echo "waiting for '$svc' to be healthy (timeout ${timeout}s)..." + while :; do + cid="$(cid_for "$svc")" + status="" + [ -n "$cid" ] && status="$(docker inspect -f '{{if .State.Health}}{{.State.Health.Status}}{{else}}none{{end}}' "$cid" 2>/dev/null || true)" + [ "$status" = "healthy" ] && { echo " '$svc' is healthy"; break; } + if [ "$(date +%s)" -ge "$deadline" ]; then + echo "TIMEOUT: '$svc' not healthy (status=${status:-no-container})" >&2 + docker ps -a --filter "name=$svc" >&2 || true + exit 1 + fi + sleep 3 + done +done diff --git a/services/acl/.dockerignore b/services/acl/.dockerignore new file mode 100644 index 0000000..39d8eb6 --- /dev/null +++ b/services/acl/.dockerignore @@ -0,0 +1,3 @@ +**/bin +**/obj +**/*.user diff --git a/services/acl/Dockerfile b/services/acl/Dockerfile new file mode 100644 index 0000000..464d080 --- /dev/null +++ b/services/acl/Dockerfile @@ -0,0 +1,32 @@ +# Multi-stage build for the ACL service (.NET 10). +# Build context is services/acl (see infra/docker-compose.yml). +FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build +WORKDIR /src + +# Restore first (cached unless .csproj files change). +COPY Acl.Api/Acl.Api.csproj Acl.Api/ +COPY Acl.Application/Acl.Application.csproj Acl.Application/ +COPY Acl.Infrastructure/Acl.Infrastructure.csproj Acl.Infrastructure/ +RUN dotnet restore Acl.Api/Acl.Api.csproj + +COPY Acl.Api/ Acl.Api/ +COPY Acl.Application/ Acl.Application/ +COPY Acl.Infrastructure/ Acl.Infrastructure/ +RUN dotnet publish Acl.Api/Acl.Api.csproj -c Release -o /app/publish /p:UseAppHost=false + +FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS runtime +WORKDIR /app + +RUN apt-get update \ + && apt-get install -y --no-install-recommends curl \ + && rm -rf /var/lib/apt/lists/* + +COPY --from=build /app/publish . + +ENV ASPNETCORE_URLS=http://+:8080 +EXPOSE 8080 + +HEALTHCHECK --interval=5s --timeout=3s --start-period=10s --retries=5 \ + CMD curl -fsS http://localhost:8080/health || exit 1 + +ENTRYPOINT ["dotnet", "Acl.Api.dll"]