From 7236e0c1bed4213c1c8f8948b7fd4d8263b28980 Mon Sep 17 00:00:00 2001 From: Stephan Renatus Date: Thu, 18 Jul 2024 14:13:48 +0200 Subject: [PATCH] opa-react-demo: add RP connect and djblue/portal for DL viewing This introduces an out-of-band web UI for inspecting decision logs. When the services are up, you can view the decision logs via Portal on http://127.0.0.1:5678. --- opa-react-demo/connect.yml | 20 ++++++++++++++++++++ opa-react-demo/docker-compose.yaml | 18 ++++++++++++++++++ opa-react-demo/eopa.yml | 8 ++++++++ opa-react-demo/portal/Dockerfile | 7 +++++++ opa-react-demo/portal/deps.edn | 1 + opa-react-demo/portal/src/start.clj | 6 ++++++ 6 files changed, 60 insertions(+) create mode 100644 opa-react-demo/connect.yml create mode 100644 opa-react-demo/eopa.yml create mode 100644 opa-react-demo/portal/Dockerfile create mode 100644 opa-react-demo/portal/deps.edn create mode 100644 opa-react-demo/portal/src/start.clj diff --git a/opa-react-demo/connect.yml b/opa-react-demo/connect.yml new file mode 100644 index 0000000..88c5a09 --- /dev/null +++ b/opa-react-demo/connect.yml @@ -0,0 +1,20 @@ +input: + broker: + inputs: + - http_server: + path: /post/logs + processors: + - decompress: + algorithm: gzip + - unarchive: + format: json_array + +buffer: + memory: {} + +output: + http_client: + url: http://portal:5678/submit + verb: POST + headers: + "Content-Type": application/json diff --git a/opa-react-demo/docker-compose.yaml b/opa-react-demo/docker-compose.yaml index 7fb0835..412b512 100644 --- a/opa-react-demo/docker-compose.yaml +++ b/opa-react-demo/docker-compose.yaml @@ -15,8 +15,26 @@ services: - --server - --addr=:8181 - --log-level=debug + - --config-file=/eopa.yml - /policies volumes: - ./policies:/policies + - ./eopa.yml:/eopa.yml environment: EOPA_LICENSE_KEY: ${EOPA_LICENSE_KEY} + + portal: + build: portal + ports: + - "5678:5678" + + connect: + image: docker.redpanda.com/redpandadata/redpanda:latest + ports: + - "4195:4195" + command: + - connect + - run + - /connect.yml + volumes: + - ./connect.yml:/connect.yml diff --git a/opa-react-demo/eopa.yml b/opa-react-demo/eopa.yml new file mode 100644 index 0000000..bdfbe2e --- /dev/null +++ b/opa-react-demo/eopa.yml @@ -0,0 +1,8 @@ +services: +- name: connect + url: http://connect:4195/post +decision_logs: + service: connect + reporting: + min_delay_seconds: 0 + max_delay_seconds: 1 diff --git a/opa-react-demo/portal/Dockerfile b/opa-react-demo/portal/Dockerfile new file mode 100644 index 0000000..ff936ef --- /dev/null +++ b/opa-react-demo/portal/Dockerfile @@ -0,0 +1,7 @@ +FROM clojure:tools-deps-bullseye-slim +WORKDIR /app +COPY . . + +EXPOSE 5678 +# TODO(sr): build at build time, run uberjar here +ENTRYPOINT ["clj", "-X", "start/run"] diff --git a/opa-react-demo/portal/deps.edn b/opa-react-demo/portal/deps.edn new file mode 100644 index 0000000..b8acca5 --- /dev/null +++ b/opa-react-demo/portal/deps.edn @@ -0,0 +1 @@ +{:deps {djblue/portal {:mvn/version "0.57.0"}}} diff --git a/opa-react-demo/portal/src/start.clj b/opa-react-demo/portal/src/start.clj new file mode 100644 index 0000000..241c789 --- /dev/null +++ b/opa-react-demo/portal/src/start.clj @@ -0,0 +1,6 @@ +(ns start + (:require [portal.api :as p])) + +(defn run [_] + (p/start {:port 5678}) + @(promise))