Support ONBUILD instruction in Dockerfiles#393
Support ONBUILD instruction in Dockerfiles#393marcuslinke merged 2 commits intodocker-java:masterfrom orzeh:master
Conversation
|
@orzeh Adding all files to the build context could be problematic if there are huge files. I really don't know how docker CLI handles this, but seems the builder inspects metadata of the base image (http://docs.docker.com/engine/reference/builder/#onbuild):
|
|
@orzeh After thinking about again probably you're right. So uploading all files and ignore only those that matches patterns in |
|
@marcuslinke I agree with you. If one has to deal with huge files, he can use |
|
Wouldn't better place Dockerfile in separate directory? |
|
@KostyaSha which |
|
Any :) from my experience i always placing Dockerfile in clean directory to not have accidental uploads to build context. |
|
In general PR LGTM 👍 even if i not fully understand ONBUILD feature and all possible cases :) |
|
Ok, now I get it. I use ONBUILD when I have several Spring Boot microservices and I add them to the image as a exploded JAR to leverage Docker caching (see this blog post). Then I create base image with number of |
There was a problem hiding this comment.
According to .dockerignore doc:
the root of the context is considered to be both the working and the root directory
then pattern b excludes all files and directories that are named b in root directory of build context.
However, in this test the file named b is under directory a, so it should not be ignored. After my changes this tests fails.
Pattern */b works as expected (and described in the doc see */temp* example)
There was a problem hiding this comment.
OK, now I got it. Thanks for explanation.
|
@orzeh Thanks for contributing! |
I have rewritten the logic that adds files to the build context: now it adds all files in
Dockerfileparent directory, except those excluded by.dockerignore.I have also added some tests that demonstrates the issue, which use
ONBUILDinDockerfile.I also fixed small bug in
.dockerignoretest: exclude pattern was wrong according to the Dockerfile doc.