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

Pass env vars to docker build #91

Merged
merged 2 commits into from
Feb 9, 2016
Merged

Conversation

drewrobb
Copy link
Contributor

@drewrobb drewrobb commented Feb 2, 2016

@erikdw fixes #90, although a little bit janky because of repeating variable names 3 times...

Also, perhaps the base image should match MESOS_RELEASE, but that is a separate issue.

@dsKarthick
Copy link
Collaborator

@drewrobb Fyi, here is an alternative way of passing environment variable moby/moby#2637 (comment) . That said, I prefer your approach.

@drewrobb
Copy link
Contributor Author

drewrobb commented Feb 2, 2016

@dsKarthick cool trick!

@erikdw
Copy link
Collaborator

erikdw commented Feb 2, 2016

@drewrobb & @dsKarthick : it may actually be better to use that env file trick to integrate with docker hub. I'm not sure of how the docker hub mechanism works, and it's unclear to me how we'll set these parameters when using docker hub. Maybe they're unneeded.

I'm a bit worried that the proposed change here in #91 might not work if we don't have all those variables specified. ... Oh! You can specify a default value:

ARG <name>[=<default value>]

That should suffice until we can gain a better understanding of the docker hub integration. Maybe @brndnmtthws can speak to that?

@erikdw
Copy link
Collaborator

erikdw commented Feb 2, 2016

@DarinJ just created an issue (#92) that is directly related to this.

@@ -11,6 +11,10 @@ ENV JAVA_HOME /usr/lib/jvm/java-7-openjdk-amd64

ENV MESOS_NATIVE_JAVA_LIBRARY /usr/lib/libmesos.so

ARG MESOS_RELEASE
ARG STORM_RELEASE
ARG MIRROR
Copy link
Collaborator

Choose a reason for hiding this comment

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

@drewrobb Lets set the default values for these variables like @erikdw mentioned?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are default values set in bin/build-release.sh (since the environment variables are always set to something, so I think it would just be making those values redundantly specified unless I'm missing something?

Copy link
Collaborator

Choose a reason for hiding this comment

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

@drewrobb What happens when someone tries to do docker build -t <tag_name> directly without using the build script?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah good point, I was thinking people would only invoke build via the build-release.sh script.

@dsKarthick
Copy link
Collaborator

@erikdw Good point regarding the default values.

@dsKarthick
Copy link
Collaborator

@drewrobb @erikdw On a second thought, I feel a combination of sourcing technique and @drewrobb's build-arg technique would be better for couple of reasons
* It allows us to specify as many environment variables as we like in the env file without making $cmd in build-release.sh look big. (Related Issue: #92)
* It helps keep the Dockerfile small as well.

By combination, I mean the environment variables specified in the env script will have precedence over those we pass with build-arg trick.

Docker seems to support conditionals for RUN commands as discussed in this stackoverflow post. Not sure if it does for ARG. Maybe @drewrobb could shed some light on that.

--build-arg MESOS_RELEASE=$MESOS_RELEASE \
--build-arg STORM_RELEASE=$STORM_RELEASE \
--build-arg MIRROR=$MIRROR \
-t mesos/storm:git-`git rev-parse --short HEAD` ."
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would be cool here to embed the storm/mesos versions into the tag (possibly in the version). Then it'd be trivial to release a few different images on dockerhub. Related to #18, #83.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@DarinJ We should also make mesos/storm configurable. Something like <user_name>/<image_name> where <image_name> is something that is in accordance with #83

For now, lets keep that change separate so we don't block this PR on #83 ?

@DarinJ
Copy link
Collaborator

DarinJ commented Feb 2, 2016

Might consider using a stock Ubuntu image and installing the correct version of mesos as defined by MESOS_VERSION. Debs available here: https://open.mesosphere.com/downloads/mesos/

@brndnmtthws
Copy link
Member

👍 for parameterizing the version. I'm not sure how to make it integrate well with the automated builds on Docker hub, however.

@erikdw
Copy link
Collaborator

erikdw commented Feb 2, 2016

Ok, so the goals seem to be:

  1. Allow the bin/build-release.sh dockerImage invocation to accept configurable storm & mesos versions, and properly build the docker image with the chosen version of mesos.
  2. Allow the integration between GitHub & Docker Hub to continue working.

I think we can accomplish both of those with a combination of our ideas from this PR's conversation:

  1. Populate our Dockerfile with ARGS for the mesos & storm versions, giving them default values which will be used when we don't specify the --build-arg parameters (i.e., when Docker Hub does the build upon a commit to the mesos/storm repo).
  2. Change our Dockerfile to be based on a vanilla ubuntu image that we install mesos on top of, to allow for the mesos version to be configurable. i.e., DarinJ's idea proposed above.
  3. As an aside, something else we need to do is update the mesos dependency in the pom.xml to match the chosen mesos version.

Anyone see any issues with the proposal?

....

Oh, I see an issue with @DarinJ 's idea from my naive perspective: it's not clear how we can get the actual mesos deb package name/URL given the mesos version. There are extra bits in the package name and URL. i.e.,

I don't know what -0.2.70, -0.2.145, -0.2.190 mean nor how to predict them.

@dsKarthick
Copy link
Collaborator

@erikdw Regarding point 3, what do you think about passing the mesos and storm versions as maven parameters? Currently we grep to figure out mesos and storm versions. Instead we could pass the version we intend to build like mvn install "-Dstorm.version=0.9.6 -Dmesos.version=0.26.0?

@dsKarthick
Copy link
Collaborator

@erikdw Also regarding point 1, it would be nice to source the environment variables defined in a separate file. That way we could define global env varaiables in both here, here and wherever else?

@erikdw
Copy link
Collaborator

erikdw commented Feb 3, 2016

This feels like it is snowballing a bit. I still think there are fundamental things we need to iron out to fully satisfy the goals as specified above, but it's going to take time to figure out the "right" way to handle the weird suffix thing for the mesos packages. I've asked a question about that on the mesos dev list.

So for now in this PR, how about we just do the "ARGS with defaults" thing? (err... of course with the other changes that @drewrobb has made in bin/build-release.sh... by "just" I meant not worrying about the inconsistent pom.xml mesos dependency and inconsistent Docker base image).

@dsKarthick
Copy link
Collaborator

@erikdw Yes. I agree. Right solutions are almost always inversely propotional to quick solutions.

@drewrobb
Copy link
Contributor Author

drewrobb commented Feb 3, 2016

I like this plan. I updated my commit to include defaults (defaults that are consistent with the existing dockerfile, but not pom.xml)

@erikdw
Copy link
Collaborator

erikdw commented Feb 4, 2016

@drewrobb : that looks good to me, let me test it later tonight or tomorrow morning, I expect I'll just merge it.

@erikdw
Copy link
Collaborator

erikdw commented Feb 4, 2016

hey @drewrobb : can you please make 1 more change? pom.xml has the mesos versions as 0.24.1, can you change them to 0.25.0 so the defaults are all the same? Thanks!

@dsKarthick
Copy link
Collaborator

@drewrobb @erikdw why not mesos 0.27.0 ?

@erikdw
Copy link
Collaborator

erikdw commented Feb 4, 2016

@dsKarthick : I'm fine with 0.27.0 too, let's just be consistent in the various files where it's sprinkled around for now. I'll file an issue for follow-up work that came up in this PR.

@drewrobb : if you update the FROM base image, please note that you'll need to change it to mesosphere/mesos:0.27.0-0.2.190.ubuntu1404.

@drewrobb
Copy link
Contributor Author

drewrobb commented Feb 5, 2016

Updated to mesos 0.27.0. I tested default build locally and it worked for me.

@erikdw
Copy link
Collaborator

erikdw commented Feb 9, 2016

Thanks @drewrobb and others that contributed to the discussion. Merging!

erikdw added a commit that referenced this pull request Feb 9, 2016
@erikdw erikdw merged commit 9bd5a3e into mesos:master Feb 9, 2016
@erikdw
Copy link
Collaborator

erikdw commented Feb 22, 2016

FYI, I've filed 2 issues for a the unresolved topics that came up in this review:

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.

bin/build-release.sh dockerImage should be passed environment variables
5 participants