|
| 1 | +From a46795f12e3e012e6ec1ad08783f6f0428a3c034 Mon Sep 17 00:00:00 2001 |
| 2 | +From: 1sonofqiu <zhangjianxin@automq.com> |
| 3 | +Date: Wed, 10 Sep 2025 16:30:39 +0800 |
| 4 | +Subject: [PATCH 6/6] feat(docker): add AutoMQ Kafka Docker release workflow |
| 5 | + and update Dockerfile |
| 6 | + |
| 7 | +--- |
| 8 | + docker/jvm/Dockerfile | 58 +++++++++++-------------------------------- |
| 9 | + docker/jvm/launch | 16 ------------ |
| 10 | + 2 files changed, 15 insertions(+), 59 deletions(-) |
| 11 | + |
| 12 | +diff --git a/docker/jvm/Dockerfile b/docker/jvm/Dockerfile |
| 13 | +index 72e35e63c0..de97104271 100644 |
| 14 | +--- a/docker/jvm/Dockerfile |
| 15 | ++++ b/docker/jvm/Dockerfile |
| 16 | +@@ -16,60 +16,31 @@ |
| 17 | + # limitations under the License. |
| 18 | + ############################################################################### |
| 19 | + |
| 20 | +-FROM eclipse-temurin:21-jre-alpine AS build-jsa |
| 21 | +- |
| 22 | +-USER root |
| 23 | +- |
| 24 | +-# Get kafka from https://archive.apache.org/dist/kafka and pass the url through build arguments |
| 25 | +-ARG kafka_url |
| 26 | +- |
| 27 | +-COPY jsa_launch /etc/kafka/docker/jsa_launch |
| 28 | +- |
| 29 | +-RUN set -eux ; \ |
| 30 | +- apk update ; \ |
| 31 | +- apk upgrade ; \ |
| 32 | +- apk add --no-cache wget gcompat gpg gpg-agent procps bash; \ |
| 33 | +- mkdir opt/kafka; \ |
| 34 | +- wget -nv -O kafka.tgz "$kafka_url"; \ |
| 35 | +- wget -nv -O kafka.tgz.asc "$kafka_url.asc"; \ |
| 36 | +- tar xfz kafka.tgz -C /opt/kafka --strip-components 1; \ |
| 37 | +- wget -nv -O KEYS https://downloads.apache.org/kafka/KEYS; \ |
| 38 | +- gpg --import KEYS; \ |
| 39 | +- gpg --batch --verify kafka.tgz.asc kafka.tgz |
| 40 | +- |
| 41 | +-# Generate jsa files using dynamic CDS for kafka server start command and kafka storage format command |
| 42 | +-RUN /etc/kafka/docker/jsa_launch |
| 43 | +- |
| 44 | +- |
| 45 | +-FROM eclipse-temurin:21-jre-alpine |
| 46 | ++FROM amazoncorretto:17-alpine |
| 47 | + |
| 48 | + # exposed ports |
| 49 | + EXPOSE 9092 |
| 50 | + |
| 51 | + USER root |
| 52 | + |
| 53 | +-# Get kafka from https://archive.apache.org/dist/kafka and pass the url through build arguments |
| 54 | ++# Get AutoMQ URL from https://github.com/AutoMQ/automq/releases and pass the url passed through build arguments |
| 55 | + ARG kafka_url |
| 56 | + ARG build_date |
| 57 | + |
| 58 | + |
| 59 | +-LABEL org.label-schema.name="kafka" \ |
| 60 | +- org.label-schema.description="Apache Kafka" \ |
| 61 | ++LABEL org.label-schema.name="automq-kafka" \ |
| 62 | ++ org.label-schema.description="AutoMQ for Kafka" \ |
| 63 | + org.label-schema.build-date="${build_date}" \ |
| 64 | +- org.label-schema.vcs-url="https://github.com/apache/kafka" \ |
| 65 | +- maintainer="Apache Kafka" |
| 66 | ++ org.label-schema.vcs-url="https://github.com/AutoMQ/automq" \ |
| 67 | ++ maintainer="AutoMQ" |
| 68 | + |
| 69 | + RUN set -eux ; \ |
| 70 | + apk update ; \ |
| 71 | + apk upgrade ; \ |
| 72 | +- apk add --no-cache wget gcompat gpg gpg-agent procps bash; \ |
| 73 | ++ apk add --no-cache wget gcompat procps bash jemalloc; \ |
| 74 | + mkdir opt/kafka; \ |
| 75 | +- wget -nv -O kafka.tgz "$kafka_url"; \ |
| 76 | +- wget -nv -O kafka.tgz.asc "$kafka_url.asc"; \ |
| 77 | +- tar xfz kafka.tgz -C /opt/kafka --strip-components 1; \ |
| 78 | +- wget -nv -O KEYS https://downloads.apache.org/kafka/KEYS; \ |
| 79 | +- gpg --import KEYS; \ |
| 80 | +- gpg --batch --verify kafka.tgz.asc kafka.tgz; \ |
| 81 | ++ wget -nv -O automq.tgz "$kafka_url"; \ |
| 82 | ++ tar xfz automq.tgz -C /opt/kafka --strip-components 1; \ |
| 83 | + mkdir -p /var/lib/kafka/data /etc/kafka/secrets; \ |
| 84 | + mkdir -p /etc/kafka/docker /usr/logs /mnt/shared/config; \ |
| 85 | + adduser -h /home/appuser -D --shell /bin/bash appuser; \ |
| 86 | +@@ -78,16 +49,17 @@ RUN set -eux ; \ |
| 87 | + chmod -R ug+w /etc/kafka /var/lib/kafka /etc/kafka/secrets; \ |
| 88 | + cp /opt/kafka/config/log4j.properties /etc/kafka/docker/log4j.properties; \ |
| 89 | + cp /opt/kafka/config/tools-log4j.properties /etc/kafka/docker/tools-log4j.properties; \ |
| 90 | +- cp /opt/kafka/config/kraft/server.properties /etc/kafka/docker/server.properties; \ |
| 91 | +- rm kafka.tgz kafka.tgz.asc KEYS; \ |
| 92 | +- apk del wget gpg gpg-agent; \ |
| 93 | ++ cp /opt/kafka/config/kraft/reconfig-server.properties /etc/kafka/docker/server.properties; \ |
| 94 | ++ rm automq.tgz; \ |
| 95 | ++ apk del wget; \ |
| 96 | + apk cache clean; |
| 97 | + |
| 98 | +-COPY --from=build-jsa kafka.jsa /opt/kafka/kafka.jsa |
| 99 | +-COPY --from=build-jsa storage.jsa /opt/kafka/storage.jsa |
| 100 | + COPY --chown=appuser:appuser resources/common-scripts /etc/kafka/docker |
| 101 | + COPY --chown=appuser:appuser launch /etc/kafka/docker/launch |
| 102 | + |
| 103 | ++# Configure jemalloc as the memory allocator |
| 104 | ++ENV LD_PRELOAD="/usr/lib/libjemalloc.so.2" |
| 105 | ++ |
| 106 | + USER appuser |
| 107 | + |
| 108 | + VOLUME ["/etc/kafka/secrets", "/var/lib/kafka/data", "/mnt/shared/config"] |
| 109 | +diff --git a/docker/jvm/launch b/docker/jvm/launch |
| 110 | +index 6c4ca1d2e0..fa0010ff03 100755 |
| 111 | +--- a/docker/jvm/launch |
| 112 | ++++ b/docker/jvm/launch |
| 113 | +@@ -38,16 +38,6 @@ if [ "${KAFKA_JMX_PORT-}" ]; then |
| 114 | + -Dcom.sun.management.jmxremote.port=$JMX_PORT" |
| 115 | + fi |
| 116 | + |
| 117 | +-# Make a temp env variable to store user provided performance otps |
| 118 | +-if [ -z "${KAFKA_JVM_PERFORMANCE_OPTS-}" ]; then |
| 119 | +- export TEMP_KAFKA_JVM_PERFORMANCE_OPTS="" |
| 120 | +-else |
| 121 | +- export TEMP_KAFKA_JVM_PERFORMANCE_OPTS="$KAFKA_JVM_PERFORMANCE_OPTS" |
| 122 | +-fi |
| 123 | +- |
| 124 | +-# We will first use CDS for storage to format storage |
| 125 | +-export KAFKA_JVM_PERFORMANCE_OPTS="${KAFKA_JVM_PERFORMANCE_OPTS-} -XX:SharedArchiveFile=/opt/kafka/storage.jsa" |
| 126 | +- |
| 127 | + echo "===> Using provided cluster id $CLUSTER_ID ..." |
| 128 | + |
| 129 | + # Invoke the docker wrapper to setup property files and format storage |
| 130 | +@@ -58,11 +48,5 @@ result=$(/opt/kafka/bin/kafka-run-class.sh kafka.docker.KafkaDockerWrapper setup |
| 131 | + echo $result | grep -i "already formatted" || \ |
| 132 | + { echo $result && (exit 1) } |
| 133 | + |
| 134 | +-# Using temp env variable to get rid of storage CDS command |
| 135 | +-export KAFKA_JVM_PERFORMANCE_OPTS="$TEMP_KAFKA_JVM_PERFORMANCE_OPTS" |
| 136 | +- |
| 137 | +-# Now we will use CDS for kafka to start kafka server |
| 138 | +-export KAFKA_JVM_PERFORMANCE_OPTS="$KAFKA_JVM_PERFORMANCE_OPTS -XX:SharedArchiveFile=/opt/kafka/kafka.jsa" |
| 139 | +- |
| 140 | + # Start kafka broker |
| 141 | + exec /opt/kafka/bin/kafka-server-start.sh /opt/kafka/config/server.properties |
| 142 | +-- |
| 143 | +2.39.5 (Apple Git-154) |
| 144 | + |
0 commit comments