Skip to content
This repository was archived by the owner on Nov 15, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions kafka/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
FROM openjdk:11-jre-slim

RUN apt update && \
apt install -y wget
apt install -y wget curl jq

ARG KAFKA_VERSION=2.3.0
RUN mkdir /kafka
WORKDIR /kafka
RUN wget http://miroir.univ-lorraine.fr/apache/kafka/$KAFKA_VERSION/kafka_2.11-$KAFKA_VERSION.tgz
RUN tar xzf kafka_2.11-$KAFKA_VERSION.tgz --strip-components=1

# download kafka
COPY download.sh /kafka
RUN /kafka/download.sh "/kafka/kafka.tgz"
RUN tar xzf /kafka/kafka.tgz --strip-components=1

VOLUME /tmp/kafka-logs

Expand Down
19 changes: 19 additions & 0 deletions kafka/download.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/sh -e
# download kafka, code from https://github.com/wurstmeister/kafka-docker/blob/master/download-kafka.sh

KAFKA_VERSION=2.7.0
SCALA_VERSION=2.12

FILENAME="kafka_${SCALA_VERSION}-${KAFKA_VERSION}.tgz"

url=$(curl --stderr /dev/null "https://www.apache.org/dyn/closer.cgi?path=/kafka/${KAFKA_VERSION}/${FILENAME}&as_json=1" | jq -r '"\(.preferred)\(.path_info)"')

# Test to see if the suggested mirror has this version, currently pre 2.1.1 versions
# do not appear to be actively mirrored. This may also be useful if closer.cgi is down.
if [[ ! $(curl -s -f -I "${url}") ]]; then
echo "Mirror does not have desired version, downloading direct from Apache"
url="https://archive.apache.org/dist/kafka/${KAFKA_VERSION}/${FILENAME}"
fi

echo "Downloading Kafka from $url to $1"
wget "${url}" -O "$1"