On Wednesday, April 06 2022, Athos Ribeiro wrote:
Hi,
Attached is a first version of the Kafka OCI Dockerfile.
It has been based on our other snap-based Dockerfiles.
Thanks a lot, Athos.
Once everyone is happy with the Dockerfile proposed here, I will follow
up with launchpad MPs for the examples and documentation, as well as
github PRs for the OCI tests.
I decided not to add a default command or entrypoint to override the
base image one given the amount of binaries shipped by kafka (zookeeper,
the server, trogdor, producers and consumers, etc) and due to the need
of custom configuration files to execute those. Instead, we should write
good documentation on how to use the image.
This is the same approach I took with the Loki ROCK, so +1.
If you want to test the image, you could:
start zookeeper:
docker run --network=$YOUR_DOCKER_NETWORK --name=zookeeper --rm -it -p 2181:2181 $YOUR_IMAGE zookeeper-server-start.sh /etc/kafka/zookeeper.properties
start the kafka server:
docker run --name=kafka --network=$YOUR_DOCKER_NETWORK --rm -it -p 9092:9092 $YOUR_IMAGE kafka-server-start.sh /etc/kafka/server.properties --override zookeeper.connect=zookeeper:2181
leave the above running and play with client binaries:
docker run --rm -it --network $YOUR_DOCKER_NETWORK $YOUR_IMAGE kafka-topics.sh --create --partitions 1 --replication-factor 1 --topic quickstart-events --bootstrap-server kafka:9092
docker run --rm -it --network $YOUR_DOCKER_NETWORK $YOUR_IMAGE kafka-topics.sh --describe --topic quickstart-events --bootstrap-server kafka:9092
docker run --rm -it --network $YOUR_DOCKER_NETWORK $YOUR_IMAGE kafka-console-producer.sh --topic quickstart-events --bootstrap-server kafka:9092
here you may type messages and use ctrl-c to exit; then you can
inspect the messages with the consumer below.
docker run --rm -it --network $YOUR_DOCKER_NETWORK $YOUR_IMAGE kafka-console-consumer.sh --topic quickstart-events --from-beginning --bootstrap-server kafka:9092
Thank you for the detailed instructions on how to test. This made it
easier for me to verify that things are working as they should.
Please, let me know what you think.
--
Athos Ribeiro
FROM ubuntu:jammy AS snap-installer
RUN set -eux; \
apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get full-upgrade -y && \
DEBIAN_FRONTEND=noninteractive apt-get install -y \
jq curl ca-certificates squashfs-tools && \
# taken from https://snapcraft.io/docs/build-on-docker
# Alternatively, we can install snapd, and issue `snap download kafka`
curl -L -H 'Snap-CDN: none' $(curl -H 'X-Ubuntu-Series: 16' -H "X-Ubuntu-Architecture: $(dpkg --print-architecture)" 'https://api.snapcraft.io/api/v1/snaps/details/kafka?channel=rock/edge' | jq '.download_url' -r) --output kafka.snap && \
mkdir -p /snap && unsquashfs -d /snap/kafka kafka.snap
FROM ubuntu:jammy
LABEL maintainer="Ubuntu Server team <ubuntu-server@xxxxxxxxxxxxxxxx>"
ENV TZ=UTC PATH=/opt/kafka/bin:$PATH
COPY --from=snap-installer /snap/kafka/opt/kafka /opt/kafka
# Copy the manifest files from the snap
COPY --from=snap-installer /snap/kafka/snap/snapcraft.yaml /usr/share/rocks/
COPY --from=snap-installer /snap/kafka/snap/manifest.yaml /usr/share/rocks/
RUN set -eux; \
ln -s /opt/kafka/config /etc/kafka; \
Indentation is wrong here.
apt-get update; \
DEBIAN_FRONTEND=noninteractive apt-get full-upgrade -y; \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
openjdk-11-jre-headless ca-certificates tzdata \
; \
DEBIAN_FRONTEND=noninteractive apt-get remove --purge --auto-remove -y; \
rm -rf /var/lib/apt/lists/*; \
# create deb manifest
(echo "# os-release" && cat /etc/os-release && echo "# dpkg-query" && dpkg-query -f '${db:Status-Abbrev},${binary:Package},${Version},${source:Package},${Source:Version}\n' -W) > /usr/share/rocks/dpkg.query
EXPOSE 2181 9092
Otherwise, I like the simplicity of the Dockerfile and I agree with the
plan to invest on the documentation in order to explain how to use this
image.
LGTM.