2024-05-22 13:22:46 +08:00
|
|
|
# Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
# contributor license agreements. See the NOTICE file distributed with
|
|
|
|
# this work for additional information regarding copyright ownership.
|
|
|
|
# The ASF licenses this file to You under the Apache License, Version 2.0
|
|
|
|
# (the "License"); you may not use this file except in compliance with
|
|
|
|
# the License. You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
|
|
|
|
FROM ghcr.io/graalvm/graalvm-community:21 AS build-native-image
|
|
|
|
|
|
|
|
ARG kafka_url
|
|
|
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
ENV KAFKA_URL=$kafka_url
|
2024-05-31 00:54:23 +08:00
|
|
|
ENV NATIVE_IMAGE_PATH="native-image"
|
|
|
|
ENV KAFKA_DIR="/app/kafka"
|
|
|
|
ENV NATIVE_CONFIGS_DIR="/app/native-image-configs"
|
|
|
|
ENV KAFKA_LIBS_DIR="$KAFKA_DIR/libs"
|
|
|
|
ENV TARGET_PATH="$KAFKA_DIR/kafka.Kafka"
|
2024-05-22 13:22:46 +08:00
|
|
|
|
2024-05-31 00:54:23 +08:00
|
|
|
COPY native-image-configs $NATIVE_CONFIGS_DIR
|
|
|
|
COPY native_command.sh native_command.sh
|
|
|
|
|
2025-08-26 10:30:14 +08:00
|
|
|
COPY *kafka.tgz /app
|
|
|
|
|
|
|
|
RUN if [ -n "$KAFKA_URL" ]; then \
|
|
|
|
microdnf install wget; \
|
|
|
|
wget -nv -O kafka.tgz "$KAFKA_URL"; \
|
|
|
|
wget -nv -O kafka.tgz.asc "$KAFKA_URL.asc"; \
|
|
|
|
wget -nv -O KEYS https://downloads.apache.org/kafka/KEYS; \
|
|
|
|
gpg --import KEYS; \
|
|
|
|
gpg --batch --verify kafka.tgz.asc kafka.tgz; \
|
|
|
|
fi; \
|
|
|
|
mkdir $KAFKA_DIR; \
|
2024-05-31 00:54:23 +08:00
|
|
|
tar xfz kafka.tgz -C $KAFKA_DIR --strip-components 1; \
|
2024-05-22 13:22:46 +08:00
|
|
|
# Build the native-binary of the apache kafka using graalVM native-image.
|
2024-05-31 00:54:23 +08:00
|
|
|
/app/native_command.sh $NATIVE_IMAGE_PATH $NATIVE_CONFIGS_DIR $KAFKA_LIBS_DIR $TARGET_PATH
|
2024-05-22 13:22:46 +08:00
|
|
|
|
|
|
|
|
|
|
|
FROM alpine:latest
|
|
|
|
|
|
|
|
EXPOSE 9092
|
|
|
|
|
|
|
|
ARG build_date
|
|
|
|
|
|
|
|
LABEL org.label-schema.name="kafka" \
|
|
|
|
org.label-schema.description="Apache Kafka" \
|
|
|
|
org.label-schema.build-date="${build_date}" \
|
|
|
|
org.label-schema.vcs-url="https://github.com/apache/kafka" \
|
2025-09-22 23:04:42 +08:00
|
|
|
org.opencontainers.image.authors="Apache Kafka"
|
2024-05-22 13:22:46 +08:00
|
|
|
|
|
|
|
RUN apk update ; \
|
|
|
|
apk add --no-cache gcompat ; \
|
|
|
|
apk add --no-cache bash ; \
|
|
|
|
mkdir -p /etc/kafka/docker /mnt/shared/config /opt/kafka/config /etc/kafka/secrets ; \
|
|
|
|
adduser -h /home/appuser -D --shell /bin/bash appuser ; \
|
|
|
|
chown appuser:root -R /etc/kafka /opt/kafka /mnt/shared/config ; \
|
|
|
|
chmod -R ug+w /etc/kafka /opt/kafka /mnt/shared/config ;
|
|
|
|
|
2025-02-21 20:43:41 +08:00
|
|
|
COPY server.properties /etc/kafka/docker/server.properties
|
2024-05-22 13:22:46 +08:00
|
|
|
COPY --chown=appuser:root --from=build-native-image /app/kafka/kafka.Kafka /opt/kafka/
|
2025-01-10 22:58:39 +08:00
|
|
|
COPY --chown=appuser:root --from=build-native-image /app/kafka/config/log4j2.yaml /etc/kafka/docker/
|
|
|
|
COPY --chown=appuser:root --from=build-native-image /app/kafka/config/tools-log4j2.yaml /etc/kafka/docker/
|
2024-05-22 13:22:46 +08:00
|
|
|
COPY --chown=appuser:root resources/common-scripts /etc/kafka/docker/
|
|
|
|
COPY --chown=appuser:root launch /etc/kafka/docker/
|
|
|
|
|
|
|
|
USER appuser
|
|
|
|
|
|
|
|
VOLUME ["/etc/kafka/secrets", "/mnt/shared/config"]
|
|
|
|
|
|
|
|
CMD ["/etc/kafka/docker/run"]
|