diff --git a/kafka/.gitignore b/kafka/.gitignore new file mode 100644 --- /dev/null +++ b/kafka/.gitignore @@ -0,0 +1,2 @@ +kafka/kafka_2.12-2.1.1.tgz* +*tgz* \ No newline at end of file diff --git a/kafka/Dockerfile b/kafka/Dockerfile new file mode 100644 --- /dev/null +++ b/kafka/Dockerfile @@ -0,0 +1,16 @@ +ARG REGISTRY=swh-jenkins +FROM $REGISTRY/tox + +USER root +RUN DEBIAN_FRONTEND=noninteractive apt-get update && \ + apt-get install -y --no-install-recommends \ + default-jdk && \ + rm -rf /var/lib/apt/lists/* + +# install kafka +RUN wget http://apache.mirrors.ovh.net/ftp.apache.org/dist/kafka/2.1.1/kafka_2.12-2.1.1.tgz +RUN tar xvf kafka_2.12-2.1.1.tgz -C /opt +RUN ln -s /opt/kafka_2.12-2.1.1 /opt/kafka +RUN chown -R jenkins: /opt/kafka + +USER jenkins diff --git a/kafka/retrieve-kafka.sh b/kafka/retrieve-kafka.sh new file mode 100755 --- /dev/null +++ b/kafka/retrieve-kafka.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash + +kafka=kafka_2.12-2.1.1 +kafka_pkg=$kafka.tgz +kafka_root_dir=/opt +kafka_dir=$kafka_root_dir/$kafka + +echo "Kafka installation started." + +if [ ! -f $kafka_pkg ]; then + echo "Kafka download" + wget http://apache.mirrors.ovh.net/ftp.apache.org/dist/kafka/2.1.1/$kafka_pkg + echo "a2e8168e8de6b45e8fca1f2883f0744d3c5a939b70d8a47a5428b72188501d4c2fc11bc35759f2392680d4e8ecf2fa9d0e518e77fd28393afba22194ad018b10 $kafka_pkg" > $kafka_pkg.expected.sha512 + sha512sum $kafka_pkg.sha512 + + diff $kafka_pkg.expected.sha512 $kafka_pkg.sha512 + if [ $? -ne 0 ]; then + echo "Kafka download: failed to retrieve $kafka_pkg"; + exit 1 + fi + echo "Kafka download done" +fi + +if [ -d $kafka_dir ]; then + echo "Kafka extraction" + + tar xvf $kafka_pkg -C $kafka_root_dit + ln -s $kafka_root_dir/$kafka $kafka_dir + echo "Kafka extraction done" +fi + +echo "Kafka installation done. Kafka is installed at $kafka_dir"