Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Dockerfile #110

Merged
merged 25 commits into from
Oct 11, 2017
Merged

Add Dockerfile #110

merged 25 commits into from
Oct 11, 2017

Conversation

solsson
Copy link
Contributor

@solsson solsson commented Jul 6, 2017

No description provided.

solsson added a commit to solsson/docker-kafkacat that referenced this pull request Jul 6, 2017
@edenhill
Copy link
Owner

edenhill commented Jul 6, 2017

Great stuff!

Can you add an example to the README how to use it?

Dockerfile Outdated
@@ -0,0 +1,18 @@
FROM debian:stable-20170620

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello,

Is there a reason you are using the date tag and not just debian:stable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought because the release is so recent that I wanted to stress the upgrade. If we remove the date tag I guess that debian:stretch makes more sense. Years from now they'll move :stable to next release, and the build might break.

we build master anyway so the code moves too
@edenhill
Copy link
Owner

edenhill commented Jul 8, 2017

LGTM.

@ctrochalakis mind a final review?

Dockerfile Outdated

COPY . /usr/src/kafkacat

RUN runDeps=''; \

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could drop runDeps since it's empty, also, you could avoid setting -ex and use && between commands.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this just a matter of conventions, or does it have any practical implications?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll drop the runDeps. This whole block is just copy paste from a convention I tend to use on debian.

README.md Outdated

# Running in docker

There is no official image build yet but you may run `docker build -t kafkacat .` or use for example `solsson/kafkacat@sha256:3075a6ca2d8431910cf01af13acd2ef9542c8ed48547733eb5c4321364ef0b66`.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is better not to mention a specific docker image since it will become outdated soon enough.

README.md Outdated

There is no official image build yet but you may run `docker build -t kafkacat .` or use for example `solsson/kafkacat@sha256:3075a6ca2d8431910cf01af13acd2ef9542c8ed48547733eb5c4321364ef0b66`.

Example:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally I'd find the example easier to follow if it avoided detaching kafkacat instances. It's closer to how you 'd run kafkacat if it was locally installed, no need to call docker logs.

README.md Outdated
docker run --rm kafkacat --help
echo 1 > example.log
docker run --name test-producer -d -v $(pwd)/example.log:/logs/example.log --entrypoint /bin/bash --net=host kafkacat \
-c 'tail -f /logs/example.log | kafkacat -b mybroker -t logs -P'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can do that without passing example.log as a volume (assuming detach is dropped):

tail -f example.log | docker run -i --name test-producer --net=host kafkacat -b mybroker -t logs -P

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just thought this was a more interesting use case, but maybe only because I was working with log aggregation in Kubernetes.

@solsson
Copy link
Contributor Author

solsson commented Jul 9, 2017

I'll be on vacation for two weeks and resume this work once I'm back. Feel free to push to the PR.

@solsson
Copy link
Contributor Author

solsson commented Jul 20, 2017

@ctrochalakis thanks for the review. I've committed new suggestions.

Also in celebration of https://github.com/edenhill/librdkafka/releases/tag/v0.11.0 I've built:

$ docker run solsson/kafkacat@sha256:1266d140c52cb39bf314b6f22b6d7a01c4c9084781bc779fdfade51214a713a8 help
Error: -b <broker,..> missing

Usage: kafkacat <options> [file1 file2 .. | topic1 topic2 ..]]
kafkacat - Apache Kafka producer and consumer tool
https://github.com/edenhill/kafkacat
Copyright (c) 2014-2015, Magnus Edenhill
Version 1.3.1 (JSON) (librdkafka 0.11.0 builtin.features=gzip,snappy,sasl,regex,lz4,sasl_plain,plugins)

and then in b04279c reverted the version change.

solsson added a commit to StreamingMicroservicesPlatform/docker-kafka that referenced this pull request Jul 20, 2017
solsson added a commit to StreamingMicroservicesPlatform/docker-kafka that referenced this pull request Jul 20, 2017
Copy link
Owner

@edenhill edenhill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect librdkafka is not getting compiled with openssl or libsasl2 support.
It would probably makes sense to install libssl-dev and libsasl2-dev with buildDeps

Dockerfile Outdated
apt-get update && apt-get install -y $buildDeps --no-install-recommends; \
rm -rf /var/lib/apt/lists/*; \
\
cd /usr/src/kafkacat; \
echo "Source versions:"; \
cat ./bootstrap.sh | grep github_download; \
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest grep ^github_download bootstrap.sh

@solsson
Copy link
Contributor Author

solsson commented Oct 10, 2017

I suspect librdkafka is not getting compiled with openssl or libsasl2 support.

Thanks. Fixed. Do we need libsasl2-2 and libssh2-1 to stick around as runtime dependency? Now they're apt-get removed. I don't have an ssl'd kafka to test with.

I also fixed the grep as suggested.

What do you think about 2778479 and 275fade? I think they help outsiders like me produce stable builds, but they also mean that there's another version number to maintain in source, and you don't need it if you plan to publish official docker builds triggered whenever librdkafka is released.

@edenhill
Copy link
Owner

I think fixating the versions is a good idea and it isn't too bad to update the 3-4 times librdkafka is released per year.

libsasl2-2 is most likely needed during runtime, libssh* is not afaik.

echo "Source versions:"; \
grep ^github_download ./bootstrap.sh; \
\
./bootstrap.sh; \
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll want to remove tmp-bootstrap before running bootstrap to make sure it gets a clean slate

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dockerfile Outdated
rm -rf /usr/src/kafkacat/tmp-bootstrap; \
apt-get purge -y --auto-remove $buildDeps; \
rm /var/log/dpkg.log /var/log/alternatives.log /var/log/apt/*.log

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Run kafkacat -V to verify that the binary still works after package removal.

Copy link
Contributor Author

@solsson solsson Oct 10, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It bailed on lack of libcrypto. I've added all libs in 723fc0f. The resulting layer totals 10.2 MB now instead of 6.6 prior to building with libssl+libsasl. Lacking a comprehensive set of tests for the build I found it warranted to take the safe approach.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aye, add kafkacat -V as a final step which makes sure all required dependencies are in place.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@solsson
Copy link
Contributor Author

solsson commented Oct 11, 2017

I think we're done. Running it from https://hub.docker.com/r/solsson/kafkacat/ for my use cases, and it works.

@edenhill edenhill merged commit 1215518 into edenhill:master Oct 11, 2017
@edenhill
Copy link
Owner

Great stuff, thanks for this @solsson !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants