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
.dockerignore
file 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
/COPY
step is composed into a tar file that ignores the files. Also, the.dockerignore
is read once at startup and cached.As Rocker is not sending the build context before each build, only filtering for each
ADD
/COPY
command, there is hope. But due to the ignore data being read only once at startup you can't do anything funky like copying different.dockerignore
files at different stages of the build though.Use
MOUNT
One option is to continue using the
.dockerignore
as is and use a RockerMOUNT
command 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
ADD
orCOPY
into multiple commands so that you don't rely on the the.dockerignore
to filter files to the other 3 images. This would probably require yourassets
directory to be stored outside of your application root.