diff --git a/.agents/skills/reporting-docker-compose/SKILL.md b/.agents/skills/reporting-docker-compose/SKILL.md new file mode 100644 index 00000000..ff376814 --- /dev/null +++ b/.agents/skills/reporting-docker-compose/SKILL.md @@ -0,0 +1,129 @@ +--- +name: reporting-docker-compose +description: Install, verify and remove the Mifos Reporting Plugin (Eclipse BIRT) running inside Apache Fineract with Docker Compose, using the docker-compose.yml at this repository's root (PostgreSQL + a plugin build from this checkout + the apache/fineract:develop image), and generate a sample PDF report from it. Use when the user asks to install, deploy, run, start, stop, uninstall or troubleshoot the reporting plugin, BIRT reports, or Fineract with the plugin, locally or with Docker, or to generate or run a sample report. +license: MPL-2.0 +compatibility: Needs Docker with the Compose plugin (docker compose) 2.23.1 or later, curl, about 4 GB of free memory for Docker, internet access, and a clone of https://github.com/openMF/mifos-reporting-plugin. No local Java or Maven needed. Not for production. +--- + +# Install the reporting plugin with Docker Compose + +`docker-compose.yml` in the repository root starts three services: + +| Service | What it does | +|---|---| +| `db` | PostgreSQL 18 with the `fineract_tenants` and `fineract_default` databases | +| `plugin-build` | Builds the plugin JAR and collects its Eclipse BIRT libraries with Maven and JDK 25, copies the shipped report designs from `birt/reports/`, then exits | +| `fineract` | `apache/fineract:develop` with the plugin and BIRT libraries on its classpath, the designs in `/app/birt/reports` and the fonts from `birt/fonts`, on `https://localhost:8443` | + +Run every command yourself, from the repository root; don't hand the steps to the user as +instructions. Do not report success until every check in step 4 passes. + +## 1. Preflight + +Run these and stop with the error if any fails: + +```bash +docker info --format '{{.ServerVersion}} {{.MemTotal}}' # daemon running; memory in bytes +docker compose version # Compose v2 plugin +docker compose ps -a # is the stack already there? +``` + +- Docker needs about 4 GB of memory for the stack. If `MemTotal` is below 4000000000, tell the user to + raise Docker's memory limit before continuing. +- If `docker compose ps -a` lists a `fineract` container, the stack is already installed. Don't + reinstall; go to step 4 and verify it. If it is stopped, `docker compose up -d` starts it again. +- Port 8443 on localhost must be free. Run `curl --noproxy '*' -s -m 2 -o /dev/null http://127.0.0.1:8443/`. The + port is free only if curl exits with code 7 (connection refused); any other exit code, including a + TLS, empty-reply or timeout error, means something listens there. If the stack isn't running, + another program has the port. Tell the user; don't stop it yourself. + +## 2. Start + +```bash +docker compose up -d +``` + +This returns once the build has finished and Fineract's container has started. On the first run the +build takes several minutes, mostly Maven downloads; later runs reuse the `maven-repo` volume and +the build takes about a minute. Give the command a timeout of at least 20 minutes, or run it in the +background and check `docker compose ps -a` until `plugin-build` has exited. Fineract then needs +a few minutes for its and the plugin's database migrations; step 4 waits for that. + +## 3. Watch for early failures + +```bash +docker compose ps -a +``` + +| Symptom | Cause and fix | +|---|---| +| `plugin-build` exited with a non-zero code | Build failed. Show `docker compose logs --tail=80 plugin-build`. `Connect timed out` or other network errors mean Maven couldn't reach a repository: run `docker compose up -d` again once (finished downloads are kept in the `maven-repo` volume), and report the error if it fails twice | +| `fineract` stays `Created` | It waits for `plugin-build` to finish and `db` to be healthy. Not a failure while the build runs | +| `fineract` restarting or `Exited` | Show `docker compose logs --tail=100 fineract`. `Connection refused` to `db` means the database wasn't ready: `docker compose restart fineract` | +| `fineract` exits with code 137 | Out of memory. Docker needs about 4 GB; ask the user to raise the limit | +| `database "fineract_default" does not exist` | The database volume was created by an older version of `docker-compose.yml`. Ask the user before `docker compose down -v` (it deletes the data), then `docker compose up -d` | +| `UnsupportedClassVersionError` or `NoSuchMethodError` in the fineract log | The Fineract image doesn't match the Fineract version the plugin is built against. Run `docker compose pull fineract` and `docker compose up -d` | +| `port is already allocated` | Something else uses port 8443. Tell the user | +| The report answers `503` with `There is no ReportingProcessService registered` | Fineract started without the plugin. Check that `docker compose ps -a` shows `plugin-build` exited with 0, then `docker compose up -d --force-recreate plugin-build fineract` | + +## 4. Verify (all must pass) + +```bash +sh .agents/skills/reporting-docker-compose/scripts/verify-install.sh +``` + +The script waits up to 10 minutes for Fineract's health to report `UP`, then checks that: + +1. Fineract's overall health is `UP` (HTTP 200 from `actuator/health`). +2. The plugin JAR and the BIRT libraries are mounted in `/app/birt/plugin`. +3. The admin login `mifos` / `password` works on the `default` tenant. +4. `GET /fineract-provider/api/v1/runreports/Active_Loans_Details?output-type=PDF...` returns `200` + with a PDF. The plugin registers that report as type `BIRT` and renders it; a Fineract without the + plugin can't. + +It exits 0 only if all four pass, and prints the last 50 lines of the Fineract log if one fails. +Exit code 2 means `fineract` isn't running (start it with `docker compose up -d`), curl is missing, or Docker isn't reachable. +Report its PASS/FAIL lines to the user as a table. If it fails, give the failure and the log +instead of a success message. On a fresh install the report has no loans in it; that is expected. + +## 5. Tell the user how to use it + +- API base: `https://localhost:8443/fineract-provider/api/v1`. Run a report with + `GET /runreports/?output-type=PDF` (also `HTML`, `CSV`, `XLS`, `XLSX`) and the report's + parameters as `R_`. The certificate is self-signed, so use `curl -k`, and accept the + certificate once in a browser before a web app can call the API. +- Every request needs the header `Fineract-Platform-TenantId: default`. +- Admin login: `mifos` / `password` (HTTP Basic). +- If the user asks for a sample report, run this and confirm the file starts with `%PDF` + (`head -c 4 active-loans.pdf`). It saves the `Active_Loans_Details` report for the Head Office + as `active-loans.pdf` in the repository root; on a fresh install it lists no loans. + + ```bash + curl -k -s --noproxy '*' -u mifos:password -H 'Fineract-Platform-TenantId: default' -o active-loans.pdf \ + 'https://localhost:8443/fineract-provider/api/v1/runreports/Active_Loans_Details?output-type=PDF&locale=en&R_branch=1&R_loanOfficer=-1&R_currencyId=-1&R_fundId=-1&R_loanProductId=-1&R_loanPurposeId=-1' + ``` +- Report designs live in the `reports` volume at `/app/birt/reports`; designs uploaded for a tenant go + to `/app/birt/reports//`. +- To rebuild after changing the plugin source or `birt/reports/`: + `docker compose up -d --force-recreate plugin-build fineract`. + +## 6. Stop or uninstall + +```bash +docker compose stop # stop, keep the data +docker compose down # remove containers, keep the named volumes (database, plugin, reports, Maven cache) +docker compose down -v # remove everything, including the database and uploaded reports +``` + +Ask before running `down -v`: it deletes all Fineract data and uploaded report designs. Confirm with +`docker compose ps -a`, which should list nothing after `down`. + +## Rules + +- Change the system only through the commands above. Don't edit `docker-compose.yml` or the source + unless the user asks. +- Don't run `docker system prune`, `docker volume prune`, or commands that stop or remove containers + outside this Compose project. +- The database password `postgres` and the login `mifos` / `password` are fixed values for a local + demo. The database port isn't published, and Fineract listens on 127.0.0.1 only. Tell the user to + change both before exposing the install to anyone else. diff --git a/.agents/skills/reporting-docker-compose/scripts/verify-install.sh b/.agents/skills/reporting-docker-compose/scripts/verify-install.sh new file mode 100644 index 00000000..30b93d87 --- /dev/null +++ b/.agents/skills/reporting-docker-compose/scripts/verify-install.sh @@ -0,0 +1,106 @@ +#!/bin/sh +# Check a Docker Compose install of the BIRT reporting plugin: Fineract health, plugin JAR and +# BIRT libraries mounted, admin login, and a BIRT report rendered to PDF. +# Waits up to 10 minutes for Fineract to report UP. Exits 0 only if all checks pass, +# 1 if a check fails, 2 if the stack isn't running or curl is missing. +# Usage: verify-install.sh (from any directory; it uses this repository's docker-compose.yml) +# No set -e: a failing check must still reach the report below. +[ -z "${ZSH_VERSION:-}" ] || emulate sh +set -u +cd "$(dirname "$0")/../../../.." || exit 2 + +BASE=https://localhost:8443/fineract-provider +WAIT_SECONDS=600 +REPORT=Active_Loans_Details +# -1 means "all" for each filter; office 1 is the Head Office every new tenant has. +REPORT_QUERY="output-type=PDF&locale=en&R_branch=1&R_loanOfficer=-1&R_currencyId=-1&R_fundId=-1" +REPORT_QUERY="$REPORT_QUERY&R_loanProductId=-1&R_loanPurposeId=-1" +PDF=$(mktemp) || exit 2 +trap 'rm -f "$PDF"' EXIT + +# Self-signed certificate (-k); a proxy from the environment must not handle localhost. +local_curl() { curl -k --noproxy '*' -s -m 60 "$@"; } + +# Print the response body, a newline, then the HTTP status code. +curl_with_code() { local_curl -w '\n%{http_code}' "$@"; } + +# Overall health is UP only with HTTP 200: Spring Boot answers 503 when the top-level status is +# DOWN, even if a component inside the body reports "status":"UP". +health_up() { + [ "${health##*"$NL"}" = 200 ] || return 1 + case "${health%"$NL"*}" in *'"status":"UP"'*) return 0 ;; *) return 1 ;; esac +} +NL=' +' + +command -v curl >/dev/null || { echo "error: curl is needed for the checks" >&2; exit 2; } +docker info >/dev/null 2>&1 || { echo "error: the Docker daemon isn't reachable" >&2; exit 2; } +if [ -z "$(docker compose ps -q fineract 2>/dev/null)" ]; then + echo "error: fineract isn't running; run 'docker compose up -d' in the repository root first" >&2 + exit 2 +fi + +health="" +deadline=$(( $(date +%s) + WAIT_SECONDS )) +while :; do + health=$(curl_with_code "$BASE/actuator/health") + health_up && break + [ "$(date +%s)" -ge "$deadline" ] && break + # A container that exited won't come up; don't wait the full 10 minutes for it. + [ -z "$(docker compose ps -aq --status exited fineract 2>/dev/null)" ] || break + sleep 10 +done + +running=$(docker compose ps -q --status running fineract 2>/dev/null) +# Exit status, not output: ls's "No such file" message also contains the file name. +docker compose exec -T fineract test -f /app/birt/plugin/birt-plugin.jar 2>/dev/null; jar_rc=$? +libs=$(docker compose exec -T fineract sh -c 'ls /app/birt/plugin/libs | grep -c birt' 2>/dev/null) +admin=$(local_curl -X POST "$BASE/api/v1/authentication" \ + -H 'Content-Type: application/json' -H 'Fineract-Platform-TenantId: default' \ + -d '{"username":"mifos","password":"password"}') +# Fineract alone has no BIRT engine: it answers 503 "There is no ReportingProcessService +# registered" here. Only the plugin answers with a PDF. +# The first report after a start also loads the BIRT engine, so it gets a longer timeout. +meta=$(local_curl -m 180 -o "$PDF" -w '%{http_code} %{content_type}' -u mifos:password \ + -H 'Fineract-Platform-TenantId: default' "$BASE/api/v1/runreports/$REPORT?$REPORT_QUERY") +# A transfer cut off after the first bytes leaves a partial PDF; only curl's exit status shows it. +report_rc=$? +magic=$(head -c 4 "$PDF" 2>/dev/null) + +failed=0 +# Print a PASS or FAIL line and remember a failure. Usage: report +report() { + if [ "$2" -eq 0 ]; then echo "PASS $1: $3"; else echo "FAIL $1: $3"; failed=1; fi +} +if health_up; then + report "Fineract health" 0 "UP" +else + body=$(printf '%s' "${health%"$NL"*}" | head -c 200) + report "Fineract health" 1 "not UP (HTTP ${health##*"$NL"}: ${body:-no response})" +fi +if [ -z "$running" ]; then + report "Plugin mounted" 1 "can't check: the fineract container isn't running (see the log below)" +elif [ "$jar_rc" -eq 0 ] && [ "${libs:-0}" -gt 0 ]; then + report "Plugin mounted" 0 "/app/birt/plugin/birt-plugin.jar and $libs BIRT libraries" +else + report "Plugin mounted" 1 "plugin JAR or BIRT libraries missing in /app/birt/plugin" +fi +login="Admin login mifos/default tenant" +case "$admin" in + *'"authenticated":true'*) report "$login" 0 '"authenticated":true' ;; + *) report "$login" 1 "$(printf '%s' "${admin:-no response}" | head -c 200)" ;; +esac +probe="GET /api/v1/runreports/$REPORT (PDF)" +case "$report_rc:$meta:$magic" in + "0:200 application/pdf"*:%PDF) + report "BIRT report" 0 "$probe -> 200, $(wc -c < "$PDF" | tr -d ' ') byte PDF" ;; + *) report "BIRT report" 1 "$probe -> ${meta:-no response} (curl exit $report_rc):\ + $(head -c 200 "$PDF" 2>/dev/null | LC_ALL=C tr -d '\0')" ;; +esac + +if [ $failed -ne 0 ]; then + echo + echo "Last 50 lines of the fineract log:" + docker compose logs --tail=50 fineract +fi +exit $failed diff --git a/README.md b/README.md index fd94ba78..7905f048 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,113 @@ The reporting engine determines the base report directory using the following hi --- +## Quick Start with Docker Compose + +To try the plugin you need three things running together: a database, the plugin built from this repository, and an Apache Fineract® server that loads it. Docker Compose starts all three from one file with one command, so you don't install Java, Maven or PostgreSQL® yourself. An AI coding agent can also do the whole setup for you; see [Install with an AI Agent](#install-with-an-ai-agent). + +[`docker-compose.yml`](docker-compose.yml) runs the plugin inside Apache Fineract® on your machine. You only need Docker® with Compose 2.23.1 or later (`docker compose version`), about 4 GB of memory for Docker®, and internet access for the images and Maven dependencies. Java and Maven run inside a container. + +```bash +git clone https://github.com/openMF/mifos-reporting-plugin.git +cd mifos-reporting-plugin +docker compose up -d +sh .agents/skills/reporting-docker-compose/scripts/verify-install.sh +``` + +It starts PostgreSQL®, builds the plugin JAR and collects its Eclipse BIRT® libraries from your checkout, and starts `apache/fineract:develop` with both on its classpath. The report designs from `birt/reports/` are copied into a `reports` volume mounted at `/app/birt/reports`, and the fonts from `birt/fonts/` are mounted at `/app/birt/fonts`. The plugin runs its own Liquibase migrations on every tenant when Apache Fineract® starts. + +With an empty Maven cache the first build downloads every dependency; on a laptop it took 8 minutes. If it stops with `Connect timed out`, run `docker compose up -d` again: finished downloads are kept in the `maven-repo` volume. Apache Fineract® with the plugin is up about 2 minutes after the build. The verify script waits for it and prints a PASS or FAIL line for health, the mounted plugin and BIRT libraries, the admin login, and the `Active_Loans_Details` report rendered as a PDF (an Apache Fineract® without the plugin answers `503` there). + +* API: `https://localhost:8443/fineract-provider/api/v1` (self-signed certificate, so `curl -k`), with the header `Fineract-Platform-TenantId: default`. Admin login: `mifos` / `password`. +* Run a report: `GET /runreports/?output-type=PDF` (or `HTML`, `CSV`, `XLS`, `XLSX`) with its parameters as `R_`. The report the verify script runs: + + ```bash + curl -k --noproxy '*' -u mifos:password -H 'Fineract-Platform-TenantId: default' -o active-loans.pdf \ + 'https://localhost:8443/fineract-provider/api/v1/runreports/Active_Loans_Details?output-type=PDF&locale=en&R_branch=1&R_loanOfficer=-1&R_currencyId=-1&R_fundId=-1&R_loanProductId=-1&R_loanPurposeId=-1' + ``` +* After changing the source or `birt/reports/`: `docker compose up -d --force-recreate plugin-build fineract`. +* Stop: `docker compose down`. Delete the database and uploaded designs too: `docker compose down -v`. + +The `fineract` service sets these environment variables in `docker-compose.yml` (edit them there): + +| Variable | Value | +| --- | --- | +| `FINERACT_HIKARI_JDBC_URL` | `jdbc:postgresql://db:5432/fineract_tenants` | +| `FINERACT_HIKARI_DRIVER_SOURCE_CLASS_NAME` | `org.postgresql.Driver` | +| `FINERACT_HIKARI_USERNAME` / `FINERACT_HIKARI_PASSWORD` | `postgres` / `postgres` | +| `FINERACT_DEFAULT_TENANTDB_HOSTNAME` / `FINERACT_DEFAULT_TENANTDB_PORT` | `db` / `5432` | +| `FINERACT_DEFAULT_TENANTDB_UID` / `FINERACT_DEFAULT_TENANTDB_PWD` | `postgres` / `postgres` | +| `FINERACT_DEFAULT_TENANTDB_CONN_PARAMS` | empty | +| `FINERACT_SERVER_SSL_ENABLED` / `FINERACT_SERVER_PORT` | `true` / `8443` | +| `MIFOS_BIRT_REPORTS_PATH` | `/app/birt/reports` | +| `MIFOS_BIRT_FONTS_PATH` | `/app/birt/fonts` | +| `JAVA_TOOL_OPTIONS` | `-Xmx2G` | +| `TZ` | `UTC` | + +This is a local demo setup. The database password and the admin login are fixed defaults, and Apache Fineract® listens on `127.0.0.1` only. + +### Install with an AI Agent + +[`.agents/skills/reporting-docker-compose/SKILL.md`](.agents/skills/reporting-docker-compose/SKILL.md) is an [Agent Skill](https://agentskills.io) that runs the Docker Compose install above, watches for known failures, checks the result with the verify script, and can save a sample report as a PDF. It also covers stopping and uninstalling. + +A skill is a folder with written instructions (`SKILL.md`) and, here, one script. When an agent that supports skills starts in this repository, it sees the name and one-line description of every skill in `.agents/skills/`. When your request matches a description, the agent opens the full instructions and runs the steps itself. You don't paste anything into the chat. + +Run your agent from the repository root: + +| Agent | Setup | +| --- | --- | +| Codex | None. Codex loads skills from `.agents/skills/`. Its default sandbox blocks Docker®; allow network, for example `codex exec -s workspace-write -c sandbox_workspace_write.network_access=true` | +| Pi Agent | None. Pi loads skills from `.agents/skills/` once you trust the project (`/trust`, or `pi --approve` for one run) | +| Claude Code | `mkdir -p .claude/skills && ln -s ../../.agents/skills/reporting-docker-compose .claude/skills/` | +| Hermes Agent | `hermes skills trust` in the repository root; Hermes then loads skills from `.agents/skills/` | +| OpenCode | None. OpenCode loads skills from `.agents/skills/` | + +Then ask, for example: *"Install the reporting plugin with Docker Compose and generate a sample report"*, or *"Remove the reporting plugin Docker setup"*. The agent runs `docker compose`, `verify-install.sh` and `curl`; approve those when it asks. The sample report is saved as `active-loans.pdf` in the repository root. If you'd rather not use an agent, run the four commands at the top of this section yourself, or follow [For Users](#for-users) for an existing Apache Fineract® server. + +#### OpenCode with a local model (Ollama) + +OpenCode can run the skill with `gpt-oss:20b` on your own machine through [Ollama](https://ollama.com), with no hosted model. The model needs about 13 GB of memory on top of Docker®'s 4 GB. OpenCode's default context is too small for its tools plus the skill, so create a copy of the model with a 64k context: + +```bash +ollama pull gpt-oss:20b +printf 'FROM gpt-oss:20b\nPARAMETER num_ctx 65536\n' > Modelfile +ollama create gpt-oss-20b-64k -f Modelfile && rm Modelfile +``` + +Add the model to `~/.config/opencode/opencode.json`: + +```json +{ + "$schema": "https://opencode.ai/config.json", + "provider": { + "ollama": { + "npm": "@ai-sdk/openai-compatible", + "name": "Ollama", + "options": { "baseURL": "http://localhost:11434/v1" }, + "models": { "gpt-oss-20b-64k": { "name": "gpt-oss 20B (64k context)" } } + } + } +} +``` + +Then, in the repository root: `opencode run -m ollama/gpt-oss-20b-64k "Install the reporting plugin with Docker Compose and generate a sample report."` + +#### Test results + +Each run started from an empty stack (Maven cache kept). "Passed" means the agent installed the plugin and a separate run of `verify-install.sh` afterwards passed all four checks. + +| Agent | Model | Prompt | Opened the skill | Passed | +| --- | --- | --- | --- | --- | +| Claude Code 2.1.322 | default (hosted) | *"Install the reporting plugin with Docker Compose."* | 1 of 1 | 1 of 1 (103 s) | +| Codex 0.167.1 | local `gpt-oss:20b` | same | 0 of 2 (ran `docker compose up -d` itself) | 2 of 2 | +| OpenCode 2.2.5 | local `gpt-oss:20b` | same | 3 of 5 | 3 of 5 (291–908 s) | +| Pi Agent 1.5.2 (`pi --approve`) | local `gpt-oss:20b` | same | 1 of 2 | 1 of 2 (405 s) | +| OpenCode 2.2.5 | local `gpt-oss:20b` | *"Install the reporting plugin with Docker Compose and generate a sample report."* | 1 of 2 | 1 of 2 (423 s) | + +The local model is not reliable at choosing the skill. In the failed OpenCode and Pi runs with the first prompt, it printed install instructions instead of running them. With the second prompt, the first run searched the Java sources for a report API instead. The skill's description didn't mention sample reports then; after it was added, the next run opened the skill first, installed the plugin, saved `active-loans.pdf` and passed all four checks. One run after a fix is not a success rate. Hermes Agent was not run; its row follows its documentation. + +--- + ## For Users ### 1. Create Report Directories diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..eaf4fbab --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,122 @@ +# Local demo: Apache Fineract (develop image) with this BIRT reporting plugin, on PostgreSQL. +# docker compose up -d then https://localhost:8443/fineract-provider (self-signed certificate) +# Not for production: fixed demo database password, self-signed TLS, default Fineract login. +name: reporting + +services: + db: + image: postgres:18 + environment: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: fineract_tenants + # Fineract also needs the default tenant's database; it doesn't create it. + configs: + - source: create-tenant-db + target: /docker-entrypoint-initdb.d/create-tenant-db.sql + volumes: + - db-data:/var/lib/postgresql + healthcheck: + # Over TCP: during first-run initialisation PostgreSQL listens on its Unix socket only. + test: ["CMD", "pg_isready", "-h", "127.0.0.1", "-U", "postgres"] + interval: 5s + retries: 20 + + # Builds the plugin JAR and collects the Eclipse BIRT libraries it needs (target/test-runtime/libs) + # into the "plugin" volume, and copies the shipped report designs into the "reports" volume. + # The source is mounted read-only and copied, so nothing in the checkout changes. + plugin-build: + image: maven:3.9.15-eclipse-temurin-25 + volumes: + - .:/src:ro + - plugin:/plugin + - reports:/reports + - maven-repo:/root/.m2 + command: + - sh + - -ec + - | + rm -rf /tmp/build && mkdir /tmp/build + tar -C /src --exclude=./target --exclude=./.git -cf - . | tar -C /tmp/build -xf - + cd /tmp/build + # Each dependency is looked up in the pom's extra repositories before Maven Central, about + # 1 s per miss. Resolving in parallel cuts a first build by a large factor. + mvn -B -q package -Dmaven.test.skip=true -Dspotless.check.skip=true \ + -Daether.dependencyCollector.impl=bf -Daether.dependencyCollector.bf.threads=16 \ + -Daether.connector.basic.threads=16 + jar=$$(ls target/birt-plugin-*.jar | grep -vE -- '-(sources|javadoc|tests)\.jar$$') || + { echo "error: no plugin JAR in target/" >&2; exit 1; } + # Stage first: a failed build or interrupted copy keeps the previous install. + rm -rf /plugin/.new && mkdir /plugin/.new + cp "$$jar" /plugin/.new/birt-plugin.jar + cp -r target/test-runtime/libs /plugin/.new/libs + rm -rf /plugin/libs /plugin/birt-plugin.jar + mv /plugin/.new/libs /plugin/libs && mv /plugin/.new/birt-plugin.jar /plugin/birt-plugin.jar + rmdir /plugin/.new + # Shipped designs overwrite their older copies; designs uploaded per tenant are kept. + # Copy, then rename: a running Fineract must never read a half-written design. + for f in birt/reports/*.rptdesign; do + tmp="/reports/.$${f##*/}.tmp" + cp "$$f" "$$tmp" && chown 65534:65534 "$$tmp" && mv "$$tmp" "/reports/$${f##*/}" + done + # Fineract runs as nobody and writes uploaded designs to /app/birt/reports//. + chown -R 65534:65534 /reports + ls -l /plugin /reports + + fineract: + image: apache/fineract:develop + depends_on: + db: + condition: service_healthy + plugin-build: + condition: service_completed_successfully + environment: + FINERACT_HIKARI_JDBC_URL: jdbc:postgresql://db:5432/fineract_tenants + FINERACT_HIKARI_DRIVER_SOURCE_CLASS_NAME: org.postgresql.Driver + FINERACT_HIKARI_USERNAME: postgres + FINERACT_HIKARI_PASSWORD: postgres + FINERACT_DEFAULT_TENANTDB_HOSTNAME: db + FINERACT_DEFAULT_TENANTDB_PORT: "5432" + FINERACT_DEFAULT_TENANTDB_UID: postgres + FINERACT_DEFAULT_TENANTDB_PWD: postgres + FINERACT_DEFAULT_TENANTDB_CONN_PARAMS: "" + FINERACT_SERVER_SSL_ENABLED: "true" + FINERACT_SERVER_PORT: "8443" + JAVA_TOOL_OPTIONS: -Xmx2G + TZ: UTC + # The plugin's Liquibase migration also stores /app/birt/reports per tenant (reports_dir). + MIFOS_BIRT_REPORTS_PATH: /app/birt/reports + MIFOS_BIRT_FONTS_PATH: /app/birt/fonts + volumes: + - plugin:/app/birt/plugin:ro + - reports:/app/birt/reports + - ./birt/fonts:/app/birt/fonts:ro + # The image's own classpath (/app/plugins/* first) would let the BIRT libraries replace newer + # versions of the same libraries in Fineract. Put Fineract's classpath before them instead. + entrypoint: + - sh + - -c + - >- + exec java -Duser.home=/tmp -Dfile.encoding=UTF-8 -Duser.timezone=UTC + -cp "/app/birt/plugin/birt-plugin.jar:$$(cat /app/jib-classpath-file):/app/birt/plugin/libs/*" + org.apache.fineract.ServerApplication + command: [] + ports: + - "127.0.0.1:8443:8443" + healthcheck: + test: ["CMD", "wget", "-q", "-O", "/dev/null", "--no-check-certificate", + "https://localhost:8443/fineract-provider/actuator/health"] + interval: 15s + timeout: 10s + start_period: 10m + retries: 4 + +configs: + create-tenant-db: + content: CREATE DATABASE fineract_default; + +volumes: + db-data: + plugin: + reports: + maven-repo: