id / kafka-el7-rpm

A set of scripts to package Apache Kafka into an rpm (CentOS/RedHat 7)
54 stars 40 forks source link

Added flag for whether or not including the metric libs + Docker build #2

Closed sledigabel closed 8 years ago

sledigabel commented 8 years ago

Added the ability to create the RPM from docker (useful on mac and windows hosts).

Also added the graphite metrics libs as optional (enabled by default).

Change-Id: Ifbae14f9e258e941369d8afdf58f5fa2b811b77b

sledigabel commented 8 years ago

Just updated as commented; Added the WORKDIR for convenience, changed the CMD statement, removed mock and the commented yum update line (from previous copy/paste, good call btw). Tested again, works as expected. Thanks!

id commented 8 years ago

But you still have the ADD instruction and other commands down below which are not really necessary.

What I suggest is to leave just RUN yum install -y wget make rpmdevtools instruction in the Dockerfile (in addition to required metadata) and build an image, then in docker run mount current directory (you will automatically get all the files required to build the rpm in the container), and also use -w switch for docker run to change working directory in runtime.

In addition to simpler Dockerfile and faster docker build users will be able to re-use the same image for building different kafka versions. And probably other rpms as well.

sledigabel commented 8 years ago

oh nice one I didn't see where you were coming from the first time. Will go and change that.

sledigabel commented 8 years ago

Mmmmh that approach seems to create a new issue; When mounting the local directory, it takes some random ownership (in my case 1000/50) and then rpmbuild doesn't accept it.

[17:12] [sledigab@MBP]$ docker run -ti -v $(pwd):/root kafka-build make
error: Bad owner/group: /root/kafka_2.10-0.8.2.1.tgz
make: *** [rpm] Error 1

That seems to be only causing an issue for rpmbuild because of the ownership of the source items. Obviously I can't change even temporarily the ownership of those files in the container. Docker doesn't throw an error but doesn't change the o/g.

It seems that we can either do "take-all" approach (ADD and download everything in the container and build) or we need to hack the Makefile to download the sources to some other location.

I am personally fine with any of the two.

id commented 8 years ago

The problem is just that you have *.tgz already downloaded locally. The simplest solution is to run make clean first.

Can you try to run this command:

docker run -ti -v $(pwd):/rpm -w /rpm kafka-build /bin/bash -c "make clean rpm"

/bin/bash -c is to setup $PATH.

id commented 8 years ago

Or am I missing something?

If one just clones this repo and runs those 2 docker commands, everything should work.

sledigabel commented 8 years ago

As I said, not working (for me at least) The tgz was from the make. Seems that since the make is downloading the file onto the shared volume it takes the owner/group mentioned above.

[18:23] [sledigab@SLEDIGAB-M-R028]$ docker run -ti -v $(pwd):/rpm -w /rpm kafka-build /bin/bash -c "make clean rpm"
gpg --import KEYS
gpg: directory `/root/.gnupg' created
gpg: new configuration file `/root/.gnupg/gpg.conf' created
gpg: WARNING: options in `/root/.gnupg/gpg.conf' are not yet active during this run
gpg: keyring `/root/.gnupg/secring.gpg' created
gpg: keyring `/root/.gnupg/pubring.gpg' created
gpg: /root/.gnupg/trustdb.gpg: trustdb created
gpg: key 53038328: public key "Chris Douglas <cdouglas@apache.org>" imported
gpg: key 99369B56: public key "Neha Narkhede (Key for signing code and releases) <nehanarkhede@apache.org>" imported
gpg: key 99369B56: "Neha Narkhede (Key for signing code and releases) <nehanarkhede@apache.org>" not changed
gpg: key 575A2645: public key "Neha Narkhede (Key used for signing releases) <neha.narkhede@gmail.com>" imported
gpg: key 7F1183BD: public key "Joe Stein (CODE SIGNING KEY) <joestein@apache.org>" imported
gpg: key E0A61EEA: public key "Jun Rao <junrao@gmail.com>" imported
gpg: Total number processed: 6
gpg:               imported: 5  (RSA: 5)
gpg:              unchanged: 1
gpg --verify kafka_2.10-0.8.2.1.tgz.asc kafka_2.10-0.8.2.1.tgz
gpg: Signature made Thu Feb 26 22:31:17 2015 UTC using RSA key ID E0A61EEA
gpg: Good signature from "Jun Rao <junrao@gmail.com>"
gpg: WARNING: This key is not certified with a trusted signature!
gpg:          There is no indication that the signature belongs to the owner.
Primary key fingerprint: 7452 AFD2 2A9E FB5A BF6C  66EE AB61 F70F E0A6 1EEA
error: Bad owner/group: /rpm/kafka_2.10-0.8.2.1.tgz
make: *** [rpm] Error 1

Maybe it's just me though. The logic would dictate it works. I can't imagine why rpmbuild would even complain about that anyway since it's got the read permissions. Is it working for you?

id commented 8 years ago

Ok, I got it. Yes, it is working for me. Let's leave your original solution then, it is more reliable.

Thanks for the contribution!