-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
Supporting tagging images during build #457
Conversation
c445766
to
2fde61f
Compare
+1 |
1 similar comment
👍 |
- 'tag-without-version' | ||
- 'tag-with-version:v3' | ||
- 'user/tag-with-user' | ||
- 'user/tag-with-user-and-version:v4' |
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.
Should there be tests with the same repo/image name, but different tags? e.g.
- 'user/tag-with-user-and-version:v4'
- 'user/tag-with-user-and-version:latest'
(Not sure if those tests are useful, but it is something that may be used)
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.
Ya, I suspect I will be using it that way myself. I'll add a user/tag-with-user-and-version:latest
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.
Great! Thanks for writing this feature btw!
Rebase, and added the extra tag to the test fixture |
move service._build_tag_name() to service.full_name in preparation for adding additional tags. Signed-off-by: Daniel Nephin <dnephin@gmail.com>
…n they are built. Signed-off-by: Daniel Nephin <dnephin@gmail.com>
After using this branch for a bit, I realized that doing the tagging implicitly during I've created a new |
Signed-off-by: Daniel Nephin <dnephin@gmail.com>
Hmm – I quite like the simplicity of tagging after the build. Then it behaves a bit like the On Jenkins, if you always build with a Git SHA tag, then surely they won't collide with other builds? |
True (this latest change also added support for environment variable expansion in the tags, which would be required to tag with a git sha). I think the case where it doesn't work is when you want to tag latest as well as a git sha. You'd always want to tag latest at the end of the test suite. What about adding a |
What do you need to tag latest for? @aanand what do you think? |
In production we would never use latest, but in testing, when one service depends on the image of another, we'll always want to test against the So to support that style of testing, we need to build a latest image for every service. |
I understand the argument for the tag feature as currently implemented, but I find it a bit weird that the tags specified in |
Cool, so what about inverting it then, the default could be to apply tags during build, and |
I think as long as you don't push at the end of an unsuccessful Jenkins build, your latest tag is going to be correct, right? Alternatively if you want the latest tag on your builds to only be applied on success, you could have only |
Not necessarily. Other test runs on that jenkins host will use the local docker, which already has latest. So you can potentially break or pollute other test suites that run around the same time. I guess the |
I can understand where you're coming from, but I'm just trying to figure out the minimum we need to add to Fig to make it work. Will this still work for you without the separate Aren't your builds going to collide anyway? |
They wouldn't collide because of how we treat these tags. The default tags created by fig The tags in |
Ah, understood. I think keeping this as part of In theory, you could achieve this with |
At this point, yes For #318 there is one blocker. You can't use this setup and include remote services that use a One way to do that would be to use the So that still leaves me with the requirement of having to specify the image name in a way that is safe for external use, and supports a FWIW, I don't see #318 as a unique requirement. Others have described a very similar system in #489, #428, and #159 (which has a bunch of +1s). While #159 (and #428) only cover the simple "single level" of dependencies, I feel the more general solution (of n-levels of dependencies) will cover both, and is more of a requirement for larger systems, with larger dependency trees. |
It is still an open question as to whether we're going to do something like #318. We are intentionally limiting the scope of Fig because we are working on a much better solution to this problem built into Docker itself. Ignoring #318 for now, if we can achieve what this pull request is doing by using |
Yeah, seems like a no-new-code solution would be to use
|
That's fine, I can wait on this PR and see what gets added to Docker. |
Let's revisit this after 1.0.0. :) |
Since this doesn't need to be in fig itself I've created a separate tool to do the tag+push step. I'm going to close this PR for now. |
The tool I'm using isn't open sourced yet, but it's basically something like this
If the tests pass, the tool does:
I think fig (now docker-compose) will probably support push eventually, I'm not sure when that will be though. |
@dnephin yeah, I understood you can just tag all images, its just there can be more than one docker image to push, I mean some fig.yml parsing for images that have build entry in it, figuring out the name of image from it and pushing all of them at once. Anyway, thanks for answer. I love fig's 'simplicity sweetness' and even think now that it can be damaging in some way - may be should do separate simple deploy tool. |
Ya, I think there could be value in having some companion tools for complex build scenarios, and deployment scenarios. That way fig can mostly focus on composition, with very simple build, and the companion tools can focus on the more complex scenarios for each of those. |
We still can't specify an image name of each build of compose... see use case here http://stackoverflow.com/q/30339950/535203 Neither |
See #2092 for the plan to support this |
Resolves #213
Includes:
tags
as list not string or dictThe first commit was some small cleanup in preparation for this change.
_build_tag_name()
would be confusing since it's not related totags
exactly. I believefull_name
is more clear here because it's the name used by fig to uniquely identify this service, not just the image name.The new unit tests also found a bug where
BuildError()
was not being called correctly.