New build instruction: ONBUILD defines a trigger to execute when extending an image with a new build#3254
Conversation
|
@shykes This needs rebased but I look forward to playing with this feature. |
docs/sources/use/builder.rst
Outdated
There was a problem hiding this comment.
another more general ONBUILD example - run apt-get update or yum update - not having to litter all derived Dockerfiles with that would be cool!
|
Docs - LGTM - I too look forward to more awesomeness @metalivedev @kencochrane @jamtur01 doc
|
|
My only concern is how transparent this is - obviously it's in the upstream Dockerfile but is there some way of inspecting the image and seeing the ONBUILD instructions? I don't like magic I can't introspect or things that might be unexpected for the end user. |
|
Yes, it's a new field in the image format and it will be visible in "docker inspect". We can adapt the end-user experience to give extra notice, allow more readable inspection etc. I'm open to suggestions. The only change so far is that the triggers are clearly printed out to the final build output, eg. "Executing 2 build triggers". I'm totally open to making more changes. One thing to keep in mind is that this totally sandboxed to the build context. Yes, you can upload arbitrary parts of the source directory but nothing outside it. And you can execute arbitrary commands in the container but not outside (and builds cannot be privileged currently, if they do that changes things somewhat). On Thu, Dec 19, 2013 at 3:43 PM, James Turnbull [email protected]
|
|
Hey Solomon, Do you believe this would be a better direction than required parameters (or environment variables) in the container? I realize they are slightly different requests, but it seems to solve the same "configuration" problem. |
|
@odonnellryan I think they are both useful and not mutually exclusive. |
|
@odonnellryan specifically:
So on the one hand you get more opportunities to ship an image that "just works" without tons of runtime configuration (onbuild). On the other hand when you do need runtime configuration, it's more powerful (required params). That's my current thinking anyway. |
|
@shykes Thanks Solomon! I'm going to continue working on a required param feature. I agree with where you're going. |
|
Rebased on master. Ping @crosbymichael @vieux @creack |
docs/sources/use/builder.rst
Outdated
There was a problem hiding this comment.
Please add a blank line above [...]. Without it, your example won't render. All directives (lines starting with ..) require a blank line to separate them from the text they operate on.
|
Could you give more information about when the ONBUILD instructions will be run? You say that "all on-build [sic.] instructions will be called in sequence, in the same order they were registered" but how does the execution of ONBUILD commands relate to non-ONBUILD commands? I presume that non-ONBUILD commands in the "FROM image" tree will be ignored. If that's true, then it still leaves open the question of when the inherited ONBUILD commands get executed in relation to the current Dockerfile commands (ONBUILD and other). ONBUILD in the current Dockerfile:
In your docs it seems like ONBUILD statements get deferred until the image is inherited through a FROM statement. But if the ONBUILD commands are required for image functionality, and they haven't been run, does that mean you expect people to duplicate the ONBUILD commands with RUN commands? so that the RUN gets done in the current build and the ONBUILD gets run in the future build? |
docs/sources/use/builder.rst
Outdated
There was a problem hiding this comment.
it would be better to keep using the same term, ONBUILD, instead of switching to on-build.
|
To further question, how deep does it go? For example, if I have a Dockerfile that uses ONBUILD, then build a new one FROM the result, and then have a third Dockerfile that I FROM that image in, does the third Dockerfile/FROM invoke the ONBUILD clauses too? |
|
So, in light of @metalivedev's comments, why not call the instruction This also makes it cleaner looking if we ever add future |
|
@tianon re: depth, it only applies to the next build. Triggers are not passed to "grandchildren" builds. On Fri, Dec 20, 2013 at 3:33 PM, Tianon Gravi [email protected]
|
|
|
some comments, if would be nice to check if the string after the onbuild in a valid Dockerfile command, otherwise you can produce a valid image, but that will fail if you try to build from it. Also we could improve the display, to see what are the build steps, exemple: I have to guess the first one is a |
|
|
No other supporters or even proper naysayers for |
|
-1 to the Hyphen. |
|
/cc @tianon this will help with buildpack creation |
|
Yeah not a fan of the hyphen either. For generic on-xxx I was thinking of simply an "ON" instruction |
|
Ok, I suppose that works for me. :) Taking a look at the docs, I definitely see the potential here. +1 By the way, Travis claims you need to gofmt, and I'd wager he's probably right. ;) |
|
Docs LGTM |
|
I rebased :) |
|
@shykes what about my comments in #3254 (comment) |
|
@vieux I agree checking for validity in advance would be nice, but I think we can keep it for later (presumably if you use ONBUILD you'll need to test your image yourself by building on top of it). |
|
ping @crosbymichael @creack |
|
ping @unclejack |
|
LGTM |
…BuildStep Docker-DCO-1.1-Signed-off-by: Solomon Hykes <[email protected]> (github: shykes)
|
@shykes travis failed because gofmt is needed for this code. |
…nding an image with a new build Docker-DCO-1.1-Signed-off-by: Solomon Hykes <[email protected]> (github: shykes)
|
@crosbymichael sorry about that. Rebased. |
|
Travis is still saying that I also have a few concerns about the feature as it is right now. Currently it does not display the ONBUILD instructions that are running for a child. It just says I'm just thinking about security with this so if we can actually see the actually build steps that are going to execution that would be better. # Executing 2 build triggers
#ADD settings.py /myapp/settings.py
# RUN manage.py syncdb |
Docker-DCO-1.1-Signed-off-by: Solomon Hykes <[email protected]> (github: shykes)
|
@shykes Travis is still saying that |
|
LGTM |
New build instruction: ONBUILD defines a trigger to execute when extending an image with a new build
No description provided.