Kafkatorio/modules/infra-kafka-cluster/src/kafka.Dockerfile

45 lines
1.2 KiB
Text
Raw Normal View History

2022-10-04 22:28:04 +02:00
# syntax=docker/dockerfile:1
ARG KAFKA_DL_URL=https://dlcdn.apache.org/kafka/3.1.0/kafka_2.13-3.1.0.tgz
2021-10-16 23:16:36 +02:00
2021-10-22 00:07:26 +02:00
## builder ##
2021-10-16 23:16:36 +02:00
FROM debian:11-slim as Kafka-Download
ARG KAFKA_DL_URL
WORKDIR /kafka
RUN apt-get update && apt-get install -y \
curl \
&& rm -rf /var/lib/apt/lists/*
RUN echo "Downloading Kafka from $KAFKA_DL_URL" \
&& curl "$KAFKA_DL_URL" | tar --strip-components=1 -xz \
&& echo "Finished Kafka download" \
&& ls -la
2021-10-22 00:07:26 +02:00
## Kafka ##
2021-10-16 23:36:33 +02:00
# KRaft (aka KIP-500) mode Preview Release
# https://github.com/apache/kafka/blob/041b76dc57f096be2a2d7532d917122992bff6e2/config/kraft/README.md
2021-10-22 00:07:26 +02:00
FROM openjdk:11 as kafka-kraft
2021-10-16 23:16:36 +02:00
WORKDIR /kafka
2021-10-22 00:07:26 +02:00
COPY --from=Kafka-Download /kafka .
2021-10-16 23:16:36 +02:00
# hardcoded for now, based on values from './config/kraft/server.properties'
# log.dirs
VOLUME /tmp/kraft-combined-logs
# listeners, controller.quorum.voters
2021-10-22 00:07:26 +02:00
EXPOSE 9092 9093
2021-10-16 23:16:36 +02:00
2021-10-22 00:07:26 +02:00
# Generate a cluster ID (must use this .sh to generate a UUID)
2022-06-24 14:49:52 +02:00
RUN ./bin/kafka-storage.sh random-uuid > cluster_id \
2021-10-16 23:16:36 +02:00
&& echo "Generated a Kafka Cluster ID: $(cat cluster_id)"
2022-06-24 14:15:22 +02:00
COPY ./kafka-server.properties ./server.properties
2022-06-24 15:01:24 +02:00
COPY --chmod=755 ./entrypoint.sh ./entrypoint.sh
2021-10-16 23:16:36 +02:00
2021-10-16 23:36:33 +02:00
# launch the broker in KRaft mode, which means that it runs without ZooKeeper
ENTRYPOINT ["/kafka/entrypoint.sh"]