You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kafka.apache.org by ch...@apache.org on 2026/08/25 06:52:33 UTC
(kafka) branch trunk updated: KAFKA-20448 Fix Docker image builds when using local kafka archive (#22054)
This is an automated email from the ASF dual-hosted git repository.
chia7712 pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git
The following commit(s) were added to refs/heads/trunk by this push:
new d8683419f26 KAFKA-20448 Fix Docker image builds when using local kafka archive (#22054)
d8683419f26 is described below
commit d8683419f26b36d2221eda20575981cb6375fb26
Author: sstremler <st...@gmail.com>
AuthorDate: Tue Aug 25 08:52:26 2026 +0200
KAFKA-20448 Fix Docker image builds when using local kafka archive (#22054)
Fix Docker JVM image build when using local kafka archive.
- Default ARG `kafka_url=""` in both JVM and native Dockerfiles. An
unset build arg is not exported to the shell, so `set -eux` failed with
"unbound variable". Also add `set -eux` to the native Dockerfile for
consistency.
- In `jsa_launch`, stop the broker with `kill -TERM $!` + `wait` instead
of `kafka-server-stop.sh`, which finds the PID by grepping ps and
returns before the JVM exits. Waiting on the PID guarantees the CDS
archive is written before the script checks for it.
Reviewers: dino2895 <di...@gmail.com>, Chia-Ping Tsai
<ch...@gmail.com>
---
docker/jvm/Dockerfile | 2 +-
docker/jvm/jsa_launch | 4 +++-
docker/native/Dockerfile | 5 +++--
3 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/docker/jvm/Dockerfile b/docker/jvm/Dockerfile
index 34735f6d52a..7387fc0e201 100644
--- a/docker/jvm/Dockerfile
+++ b/docker/jvm/Dockerfile
@@ -21,7 +21,7 @@ FROM docker.io/library/eclipse-temurin:21-jre-alpine AS build-jsa
USER root
# Get kafka from https://archive.apache.org/dist/kafka and pass the url through build arguments
-ARG kafka_url
+ARG kafka_url=""
COPY jsa_launch /etc/kafka/docker/jsa_launch
COPY server.properties /etc/kafka/docker/server.properties
diff --git a/docker/jvm/jsa_launch b/docker/jvm/jsa_launch
index bfb6d73fa8b..35b4b584852 100755
--- a/docker/jvm/jsa_launch
+++ b/docker/jvm/jsa_launch
@@ -20,6 +20,7 @@ TOPIC="test-topic"
KAFKA_JVM_PERFORMANCE_OPTS="-XX:ArchiveClassesAtExit=storage.jsa" opt/kafka/bin/kafka-storage.sh format --standalone -t $KAFKA_CLUSTER_ID -c opt/kafka/config/server.properties
KAFKA_JVM_PERFORMANCE_OPTS="-XX:ArchiveClassesAtExit=kafka.jsa" opt/kafka/bin/kafka-server-start.sh opt/kafka/config/server.properties &
+KAFKA_PID=$!
check_timeout() {
if [ $TIMEOUT -eq 0 ]; then
@@ -39,7 +40,8 @@ echo "test" | opt/kafka/bin/kafka-console-producer.sh --topic $TOPIC --bootstrap
opt/kafka/bin/kafka-console-consumer.sh --topic $TOPIC --from-beginning --bootstrap-server localhost:9092 --max-messages 1 --timeout-ms 20000
[ $? -eq 0 ] || exit 1
-opt/kafka/bin/kafka-server-stop.sh
+kill -TERM $KAFKA_PID
+wait $KAFKA_PID
# Wait until jsa file is generated
TIMEOUT=20
diff --git a/docker/native/Dockerfile b/docker/native/Dockerfile
index 3e863633926..77ebe745846 100644
--- a/docker/native/Dockerfile
+++ b/docker/native/Dockerfile
@@ -15,7 +15,7 @@
FROM ghcr.io/graalvm/graalvm-community:21 AS build-native-image
-ARG kafka_url
+ARG kafka_url=""
WORKDIR /app
@@ -30,7 +30,8 @@ COPY native_command.sh native_command.sh
COPY *kafka.tgz /app
-RUN if [ -n "$kafka_url" ]; then \
+RUN set -eux ; \
+ if [ -n "$kafka_url" ]; then \
microdnf install wget; \
wget -nv -O kafka.tgz "$kafka_url"; \
wget -nv -O kafka.tgz.asc "$kafka_url.asc"; \