I have one Rockerfile that builds 4 images; I also have one central .dockerignore file. For one of the images I require assets that are blocked by the .dockerignore file -- is there a way when doing ADD or COPY to force add / ignore this list?
It'll be a lot easier to do this in one file as opposed to three separate...!
In a normal Docker build the
.dockerignorefile affects the "build context" that is packaged up and sent to the docker server at the beginning of the build. If the "build context" doesn't contain the files then you can't reference them, so this is how the files are excluded. They don't "exist" for the build.Rocker claims to run differently by not sending a build context to the server. The code looks like each
ADD/COPYstep is composed into a tar file that ignores the files. Also, the.dockerignoreis read once at startup and cached.As Rocker is not sending the build context before each build, only filtering for each
ADD/COPYcommand, there is hope. But due to the ignore data being read only once at startup you can't do anything funky like copying different.dockerignorefiles at different stages of the build though.Use
MOUNTOne option is to continue using the
.dockerignoreas is and use a RockerMOUNTcommand to manually copy the ignored directories. Their last example in the mount section demonstrates:Change App Structure
The only other useful option I can think of is to split out your
ADDorCOPYinto multiple commands so that you don't rely on the the.dockerignoreto filter files to the other 3 images. This would probably require yourassetsdirectory to be stored outside of your application root.