From 94c8240baaaae40be0ab9cb5c833d5494688886f Mon Sep 17 00:00:00 2001 From: Staffan Olsson Date: Thu, 10 Mar 2022 17:16:27 +0100 Subject: [PATCH 1/3] Adds a kafka image based on solsson/dockerfiles --- hooks/build | 1 + kafka/Dockerfile | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 kafka/Dockerfile diff --git a/hooks/build b/hooks/build index c5f3499..5e6d5c7 100755 --- a/hooks/build +++ b/hooks/build @@ -31,6 +31,7 @@ node-kafka-cache runtime-quarkus-ubuntu runtime-quarkus-ubuntu-jre runtime-quarkus-dev +kafka " AMD64ONLY=" diff --git a/kafka/Dockerfile b/kafka/Dockerfile new file mode 100644 index 0000000..5976687 --- /dev/null +++ b/kafka/Dockerfile @@ -0,0 +1,28 @@ +FROM --platform=$TARGETPLATFORM yolean/runtime-quarkus-ubuntu-jre:root + +ENV KAFKA_VERSION=3.1.0 SCALA_VERSION=2.13 + +RUN set -ex; \ + export DEBIAN_FRONTEND=noninteractive; \ + runDeps='ca-certificates netcat-openbsd'; \ + buildDeps='curl gnupg dirmngr'; \ + apt-get update && apt-get install -y $runDeps $buildDeps --no-install-recommends; \ + \ + curl -f -sLS -o KEYS https://www.apache.org/dist/kafka/KEYS; \ + gpg --import KEYS && rm KEYS; \ + \ + SCALA_BINARY_VERSION=$(echo $SCALA_VERSION | cut -f 1-2 -d '.'); \ + mkdir -p /opt/kafka; \ + curl -f -sLS -o kafka_$SCALA_BINARY_VERSION-$KAFKA_VERSION.tgz.asc https://www.apache.org/dist/kafka/$KAFKA_VERSION/kafka_$SCALA_BINARY_VERSION-$KAFKA_VERSION.tgz.asc; \ + curl -f -sLS -o kafka_$SCALA_BINARY_VERSION-$KAFKA_VERSION.tgz "https://www-eu.apache.org/dist/kafka/$KAFKA_VERSION/kafka_$SCALA_BINARY_VERSION-$KAFKA_VERSION.tgz"; \ + gpg --verify kafka_$SCALA_BINARY_VERSION-$KAFKA_VERSION.tgz.asc kafka_$SCALA_BINARY_VERSION-$KAFKA_VERSION.tgz; \ + tar xzf kafka_$SCALA_BINARY_VERSION-$KAFKA_VERSION.tgz --strip-components=1 -C /opt/kafka; \ + rm kafka_$SCALA_BINARY_VERSION-$KAFKA_VERSION.tgz; \ + \ + rm -rf /opt/kafka/site-docs; \ + \ + apt-get purge -y --auto-remove $buildDeps; \ + rm -rf /var/lib/apt/lists; \ + rm -rf /var/log/dpkg.log /var/log/alternatives.log /var/log/apt /root/.gnupg + +WORKDIR /opt/kafka From 944fd9f41b2e64f68607ed26006b5384f3f2c99e Mon Sep 17 00:00:00 2001 From: Staffan Olsson Date: Fri, 11 Mar 2022 14:04:17 +0100 Subject: [PATCH 2/3] Sets default start for nonroot, fails without kafka-storage.sh --- kafka/Dockerfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kafka/Dockerfile b/kafka/Dockerfile index 5976687..46ddcb2 100644 --- a/kafka/Dockerfile +++ b/kafka/Dockerfile @@ -20,9 +20,12 @@ RUN set -ex; \ rm kafka_$SCALA_BINARY_VERSION-$KAFKA_VERSION.tgz; \ \ rm -rf /opt/kafka/site-docs; \ + mkdir /opt/kafka/logs && chgrp nogroup /opt/kafka/logs && chmod g+w /opt/kafka/logs; \ \ apt-get purge -y --auto-remove $buildDeps; \ rm -rf /var/lib/apt/lists; \ rm -rf /var/log/dpkg.log /var/log/alternatives.log /var/log/apt /root/.gnupg WORKDIR /opt/kafka +ENTRYPOINT [ "./bin/kafka-server-start.sh" ] +CMD [ "config/kraft/server.properties" ] From 936f3fe5f17cde6f8a55408455a6b9ffc523a7da Mon Sep 17 00:00:00 2001 From: Staffan Olsson Date: Fri, 11 Mar 2022 14:43:07 +0100 Subject: [PATCH 3/3] Labels base image for github.com/Yolean/kubernetes-kafka --- hooks/build | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hooks/build b/hooks/build index 5e6d5c7..36e6eac 100755 --- a/hooks/build +++ b/hooks/build @@ -86,3 +86,8 @@ done echo "amd64-only PUSH list contains: $PUSH" [ -z "$NOPUSH" ] || exit 0 for P in $PUSH; do docker push $P; done + +# Custom labling +JRE_MAJOR="$(head -n 1 java/Dockerfile | sed 's/[^:]*:\([[:digit:]]*\).*/\1/')" +KAFKA_VERSION="$(cat kafka/Dockerfile | grep 'ENV KAFKA_VERSION=' | sed 's/[^=]*=\([^ ]*\)*.*/\1/')" +crane cp yolean/kafka:latest yolean/kafka:$KAFKA_VERSION-java$JRE_MAJOR