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
Allow for Dockerfile to be named something else. #9707
Conversation
29ea78e
to
0d7bf0e
Compare
@duglin you are so fast! |
if err != nil { | ||
return fmt.Errorf("Bad .dockerignore pattern: '%s', error: %s", pattern, err) | ||
} | ||
if ok { | ||
return fmt.Errorf("Dockerfile was excluded by .dockerignore pattern '%s'", pattern) | ||
return fmt.Errorf("Dockerfile(", *dockerfileName, "was excluded by .dockerignore pattern '%s'", pattern) |
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.
This looks kinda weird, can you please use the traditional printf format here?
0d7bf0e
to
d3a86bf
Compare
IMO, I don't like that the Specifically:
The above two lines are not synonymous, because the Dockerfiles are built in different contexts. This results in two (IMO not acceptable) side effects:
IMHO, Just my $0.02. |
The "context" argument is still required, right? |
@tianon yes I think that's a typo in his example. Right now this will fail because the CLI blindly passed the -f value to the daemon w/o taking into account that we're in "foo" and the daemon will look for myDockerfile in the root of the build context. IOW, the CLI really should convert "-f myDockerfile" to "-f foo/myDockerfile" before it sends it to the REST API so the daemon will find it. @cyphar I think you're correct but let's see what other think before I change it. |
@crosbymichael I fixed the errorf stuff you noticed. |
Cool, SGTM. I think the CLI would then also need to throw an error when ADD/COPY are also going to get a little confusing here. :) |
@tianon yes, it already throws an error if -f (on the daemon) points to something outside of the context, but yes this will force an additional check on the CLI side. |
@tianon a little more confusing. The reason for the whole context beef is that Dockerfiles now will need to either reference things relative to the root context when Neither of those options sound favourable to me (also the above symmetry concerns are quite important IMO, and if we're going to add this new functionality we might as well get it right the first time :P). |
@cyphar but also, you don't have to use |
right, I think you should be able to put your dockerfile anywhere you want, but in the end any relative paths in there (e.g. on ADD/COPY) are relative to the context root. I think the docs are pretty clear on this already. |
@crosbymichael Surely they can place But idk, I might be acting far too idealistically for a feature like this. |
@cyphar are you saying you don't think I should make your suggested change? |
@duglin Nono, I think that the change should be made. I just thought I was the only one who thought that :P. |
I'm not sure about what we talking about, if context parameter is still necessary. |
@LK4D4 Oh, I completely forgot about the context parameter. That makes
Or should it assume that you want the context to be |
@cyphar Yes, you have to do this. |
so I guess the question is: |
Just wanted to add that I think we have a potential backwards incompatible change here. Because having that kind of structure:
and running |
@slafs no it should not change that, if it does then I broke something :-) |
Hope I'm not messing up the discussion with this, but something I brought up in #7284; Should each Dockerfile also be able to have its own My use case; being able to build multiple images (dev/prod) from the same context, but exclude some large files (or large amount of files) from the image that are not needed when building a dev image. Being able to exclude those files gives a huge speed gain when building the image. |
@duglin what you said here sounds like what we would expect as an end user "As an end user, my first reaction was to think it should be relative to the current dir." We can go that route. |
@thaJeztah if we did want to support multiple .dockerignores then I would think it could be done in a similar way to the -f option, so: -i/--ignore=file but I think that would be a new PR. |
d3a86bf
to
2c7ffeb
Compare
@duglin need rebase :) sorry |
c6c1dda
to
f057e20
Compare
@LK4D4 ok rebased |
|
||
if *dockerfileName == "" { | ||
// No -f/--file was specified so use the default | ||
origDockerfile = "Dockerfile" |
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.
can we make this a constant?
need the constant, otherwise LGTM |
f057e20
to
7266dba
Compare
@erikh ok created a constant and used it on client and server |
7266dba
to
179f202
Compare
ok rebased and constant is made/used. |
@duglin Either we are working really fast today or you forgot to push your rebase ;) |
Add a check to make sure Dockerfile is in the build context Add docs and a testcase Make -f relative to current dir, not build context Signed-off-by: Doug Davis <dug@us.ibm.com>
179f202
to
eb3ea3b
Compare
Nice |
Cool, i think this has enough LGTMs |
Allow for Dockerfile to be named something else.
We also need this feature on the DockerHub (hub.docker.com) for it's Automated Builds. In the 'Edit Build Settings' page where it has the Field named 'Dockerfile Location'. |
NOTE on Oct 13, 2015: This patch has now been obsoleted, since the merge of moby#9707 moby#9707 END NOTE Now one can perform the following commands in the same directory: docker build -t db_container -f db.dockerfile . docker build -t web_container -f web.dockerfile . docker build -t client_container -f client.dockerfile . docker build -t client_container . The last one will use the default Dockerfile file.
This is a follow-on to #7995 and #7284.
This PR allows for the Dockerfile to be named something other than
Dockerfile
via a -f/--file option. Aside from the name/path of the Dockerfile being variable, nothing else should change from today's behavior. The location of the Dockerfile MUST be within the build context.This PR contains the:
Signed-off-by: Doug Davis dug@us.ibm.com