Skip to content

Commit bca4124

Browse files
labrenbedervoeti
andauthored
feat(kafka): Build kafka-opa-plugin from source (#1177)
* build kafka-opa-plugin from source * add changelog entry * Apply suggestions from code review clean up Dockerfile Co-authored-by: Lukas Krug <[email protected]> --------- Co-authored-by: Lukas Krug <[email protected]>
1 parent f1e5c07 commit bca4124

File tree

8 files changed

+45
-9
lines changed

8 files changed

+45
-9
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ All notable changes to this project will be documented in this file.
2222
- spark-connect-client: A new image for Spark connect tests and demos ([#1034])
2323
- kafka: check for correct permissions and ownerships in /stackable folder via
2424
`check-permissions-ownership.sh` provided in stackable-base image ([#1041]).
25+
- kafka: build kafka-opa-plugin from source ([#1177]).
2526
- nifi: check for correct permissions and ownerships in /stackable folder via
2627
`check-permissions-ownership.sh` provided in stackable-base image ([#1027]).
2728
- nifi: Add [nifi-iceberg-bundle] for NiFi `2.4.0` ([#1060], [#1106]).
@@ -202,6 +203,7 @@ All notable changes to this project will be documented in this file.
202203
[#1171]: https://github.com/stackabletech/docker-images/pull/1171
203204
[#1173]: https://github.com/stackabletech/docker-images/pull/1173
204205
[#1174]: https://github.com/stackabletech/docker-images/pull/1174
206+
[#1177]: https://github.com/stackabletech/docker-images/pull/1177
205207
[#1179]: https://github.com/stackabletech/docker-images/pull/1179
206208
[#1180]: https://github.com/stackabletech/docker-images/pull/1180
207209
[#1184]: https://github.com/stackabletech/docker-images/pull/1184

conf.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
trino_storage_connector = importlib.import_module("trino.storage-connector.versions")
3939
kafka_testing_tools = importlib.import_module("kafka-testing-tools.versions")
4040
kcat = importlib.import_module("kafka.kcat.versions")
41+
kafka_opa_plugin = importlib.import_module("kafka.kafka-opa-plugin.versions")
4142
testing_tools = importlib.import_module("testing-tools.versions")
4243
zookeeper = importlib.import_module("zookeeper.versions")
4344
tools = importlib.import_module("tools.versions")
@@ -73,6 +74,7 @@
7374
{"name": "trino/storage-connector", "versions": trino_storage_connector.versions},
7475
{"name": "kafka-testing-tools", "versions": kafka_testing_tools.versions},
7576
{"name": "kafka/kcat", "versions": kcat.versions},
77+
{"name": "kafka/kafka-opa-plugin", "versions": kafka_opa_plugin.versions},
7678
{"name": "testing-tools", "versions": testing_tools.versions},
7779
{"name": "zookeeper", "versions": zookeeper.versions},
7880
{"name": "tools", "versions": tools.versions},

kafka/Dockerfile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
# check=error=true
33

44
FROM stackable/image/kafka/kcat AS kcat
5+
FROM stackable/image/kafka/kafka-opa-plugin AS kafka-opa-plugin
56

67
FROM stackable/image/java-devel AS kafka-builder
78

89
ARG PRODUCT
910
ARG RELEASE
1011
ARG SCALA
11-
ARG OPA_AUTHORIZER
1212
ARG JMX_EXPORTER
1313
ARG STACKABLE_USER_UID
1414

@@ -40,10 +40,6 @@ cp build/reports/bom.json /stackable/kafka_${SCALA}-${NEW_VERSION}.cdx.json
4040
rm -rf /stackable/kafka_${SCALA}-${NEW_VERSION}/site-docs/
4141
(cd .. && rm -rf ${PRODUCT})
4242

43-
# TODO (@NickLarsenNZ): Compile from source: https://github.com/StyraInc/opa-kafka-plugin
44-
curl https://repo.stackable.tech/repository/packages/kafka-opa-authorizer/opa-authorizer-${OPA_AUTHORIZER}-all.jar \
45-
-o /stackable/kafka_${SCALA}-${NEW_VERSION}/libs/opa-authorizer-${OPA_AUTHORIZER}-all.jar
46-
4743
# JMX exporter
4844
curl https://repo.stackable.tech/repository/packages/jmx-exporter/jmx_prometheus_javaagent-${JMX_EXPORTER}.jar \
4945
-o /stackable/jmx/jmx_prometheus_javaagent-${JMX_EXPORTER}.jar
@@ -60,6 +56,7 @@ ARG RELEASE
6056
ARG PRODUCT
6157
ARG SCALA
6258
ARG KAFKA_KCAT
59+
ARG KAFKA_KAFKA_OPA_PLUGIN
6360
ARG STACKABLE_USER_UID
6461

6562
LABEL \
@@ -78,6 +75,8 @@ COPY --chown=${STACKABLE_USER_UID}:0 --from=kafka-builder /stackable/jmx/ /stack
7875
COPY --chown=${STACKABLE_USER_UID}:0 --from=kcat /stackable/kcat /stackable/bin/kcat-${KAFKA_KCAT}
7976
COPY --chown=${STACKABLE_USER_UID}:0 --from=kcat /stackable/kcat-${KAFKA_KCAT}-src.tar.gz /stackable
8077
COPY --chown=${STACKABLE_USER_UID}:0 --from=kcat /licenses /licenses
78+
COPY --chown=${STACKABLE_USER_UID}:0 --from=kafka-opa-plugin /stackable/src/kafka/kafka-opa-plugin/patchable-work/worktree/${KAFKA_KAFKA_OPA_PLUGIN}/build/libs/opa-authorizer-${KAFKA_KAFKA_OPA_PLUGIN}-all.jar /stackable/kafka_${SCALA}-${PRODUCT}-stackable${RELEASE}/libs/opa-authorizer-${KAFKA_KAFKA_OPA_PLUGIN}-all.jar
79+
COPY --chown=${STACKABLE_USER_UID}:0 --from=kafka-opa-plugin /stackable/kafka-opa-plugin-${KAFKA_KAFKA_OPA_PLUGIN}-src.tar.gz /stackable
8180

8281
COPY --chown=${STACKABLE_USER_UID}:0 kafka/licenses /licenses
8382

@@ -107,6 +106,7 @@ chown -h ${STACKABLE_USER_UID}:0 /stackable/kafka
107106
chmod g=u /stackable/bin
108107
chmod g=u /stackable/jmx
109108
chmod g=u /stackable/kafka_${SCALA}-${PRODUCT}-stackable${RELEASE}
109+
chmod g=u /stackable/kafka_${SCALA}-${PRODUCT}-stackable${RELEASE}/libs/opa-authorizer-${KAFKA_KAFKA_OPA_PLUGIN}-all.jar
110110
chmod g=u /stackable/*-src.tar.gz
111111
EOF
112112

kafka/kafka-opa-plugin/Dockerfile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# syntax=docker/dockerfile:1.16.0@sha256:e2dd261f92e4b763d789984f6eab84be66ab4f5f08052316d8eb8f173593acf7
2+
# check=error=true
3+
4+
FROM stackable/image/java-devel
5+
6+
ARG PRODUCT
7+
ARG STACKABLE_USER_UID
8+
9+
USER ${STACKABLE_USER_UID}
10+
WORKDIR /stackable
11+
12+
COPY --chown=${STACKABLE_USER_UID}:0 kafka/kafka-opa-plugin/stackable/patches/patchable.toml /stackable/src/kafka/kafka-opa-plugin/stackable/patches/patchable.toml
13+
COPY --chown=${STACKABLE_USER_UID}:0 kafka/kafka-opa-plugin/stackable/patches/${PRODUCT} /stackable/src/kafka/kafka-opa-plugin/stackable/patches/${PRODUCT}
14+
15+
RUN <<EOF
16+
cd "$(/stackable/patchable --images-repo-root=src checkout kafka/kafka-opa-plugin ${PRODUCT})"
17+
18+
# Create snapshot of the source code including custom patches
19+
tar -czf /stackable/kafka-opa-plugin-${PRODUCT}-src.tar.gz .
20+
21+
./gradlew clean shadowJar
22+
EOF
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
mirror = "https://github.com/stackabletech/opa-kafka-plugin"
2+
base = "d2c7851cb66dde7903eb4f0d5fab40f1a3d434a4"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
upstream = "https://github.com/StyraInc/opa-kafka-plugin"
2+
default-mirror = "https://github.com/stackabletech/opa-kafka-plugin"

kafka/kafka-opa-plugin/versions.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
versions = [
2+
{
3+
"product": "1.5.1",
4+
"java-devel": "11",
5+
},
6+
]

kafka/versions.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"java-devel": "21",
66
"scala": "2.13",
77
"kafka/kcat": "1.7.0",
8-
"opa_authorizer": "1.5.1",
8+
"kafka/kafka-opa-plugin": "1.5.1",
99
"jmx_exporter": "1.3.0",
1010
},
1111
{
@@ -14,7 +14,7 @@
1414
"java-devel": "21",
1515
"scala": "2.13",
1616
"kafka/kcat": "1.7.0",
17-
"opa_authorizer": "1.5.1",
17+
"kafka/kafka-opa-plugin": "1.5.1",
1818
"jmx_exporter": "1.3.0",
1919
},
2020
{
@@ -23,7 +23,7 @@
2323
"java-devel": "21",
2424
"scala": "2.13",
2525
"kafka/kcat": "1.7.0",
26-
"opa_authorizer": "1.5.1",
26+
"kafka/kafka-opa-plugin": "1.5.1",
2727
"jmx_exporter": "1.3.0",
2828
},
2929
{
@@ -32,7 +32,7 @@
3232
"java-devel": "23",
3333
"scala": "2.13",
3434
"kafka/kcat": "1.7.0",
35-
"opa_authorizer": "1.5.1",
35+
"kafka/kafka-opa-plugin": "1.5.1",
3636
"jmx_exporter": "1.3.0",
3737
},
3838
]

0 commit comments

Comments
 (0)