Dockerfile.kafka 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. FROM registry.access.redhat.com/ubi8/ubi-minimal:8.9@sha256:f30dbf77b075215f6c827c269c073b5e0973e5cea8dacdf7ecb6a19c868f37f2
  2. USER root
  3. RUN microdnf update -y \
  4. && microdnf install -y curl gzip java-11-openjdk-headless tar tzdata-java \
  5. && microdnf reinstall -y tzdata \
  6. && microdnf clean all
  7. ENV JAVA_HOME=/usr/lib/jvm/jre-11
  8. # https://docs.oracle.com/javase/7/docs/technotes/guides/net/properties.html
  9. # Ensure Java doesn't cache any dns results
  10. RUN cd /etc/java/java-11-openjdk/*/conf/security \
  11. && sed -e '/networkaddress.cache.ttl/d' -e '/networkaddress.cache.negative.ttl/d' -i java.security \
  12. && echo 'networkaddress.cache.ttl=0' >> java.security \
  13. && echo 'networkaddress.cache.negative.ttl=0' >> java.security
  14. ARG SCALA_VERSION="2.13"
  15. ARG KAFKA_VERSION="3.6.0"
  16. # https://github.com/apache/kafka/blob/9989b68d0d38c8f1357f78bf9d53a58c1476188d/tests/docker/Dockerfile#L46-L72
  17. ARG KAFKA_MIRROR="https://s3-us-west-2.amazonaws.com/kafka-packages"
  18. SHELL ["/bin/bash", "-o", "pipefail", "-c"]
  19. RUN mkdir -p "/opt/kafka-${KAFKA_VERSION}" \
  20. && chmod a+rw "/opt/kafka-${KAFKA_VERSION}" \
  21. && curl -s "$KAFKA_MIRROR/kafka_${SCALA_VERSION}-${KAFKA_VERSION}.tgz" | tar xz --strip-components=1 -C "/opt/kafka-${KAFKA_VERSION}"
  22. # older kafka versions depend upon jaxb-api being bundled with the JDK, but it
  23. # was removed from Java 11 so work around that by including it in the kafka
  24. # libs dir regardless
  25. WORKDIR /tmp
  26. RUN curl -sLO "https://repo1.maven.org/maven2/javax/xml/bind/jaxb-api/2.3.0/jaxb-api-2.3.0.jar" \
  27. && for DIR in /opt/kafka-*; do cp -v jaxb-api-2.3.0.jar $DIR/libs/ ; done \
  28. && rm -f jaxb-api-2.3.0.jar
  29. WORKDIR /opt/kafka-${KAFKA_VERSION}
  30. ENV JAVA_MAJOR_VERSION=11
  31. RUN sed -e "s/JAVA_MAJOR_VERSION=.*/JAVA_MAJOR_VERSION=${JAVA_MAJOR_VERSION}/" -i"" ./bin/kafka-run-class.sh
  32. COPY entrypoint.sh /
  33. USER 65534:65534
  34. ENTRYPOINT ["/entrypoint.sh"]