-
Notifications
You must be signed in to change notification settings - Fork 475
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
Add Dockerfile #110
Conversation
Great stuff! Can you add an example to the README how to use it? |
Dockerfile
Outdated
@@ -0,0 +1,18 @@ | |||
FROM debian:stable-20170620 |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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
LGTM. @ctrochalakis mind a final review? |
Dockerfile
Outdated
|
||
COPY . /usr/src/kafkacat | ||
|
||
RUN runDeps=''; \ |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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`. |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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' |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
I'll be on vacation for two weeks and resume this work once I'm back. Feel free to push to the PR. |
…uild" This reverts commit cafd5e2.
@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:
and then in b04279c reverted the version change. |
There was a problem hiding this 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; \ |
There was a problem hiding this comment.
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
Thanks. Fixed. Do we need 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. |
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; \ |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 | ||
|
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we're done. Running it from https://hub.docker.com/r/solsson/kafkacat/ for my use cases, and it works. |
Great stuff, thanks for this @solsson ! |
No description provided.