Glob style copy in dockerfiles

Support the ability to copy all files of a given extension to the same destination folder as the source folder.

So, for example:

On the host machine:

  • /test/test1.src
  • /test/random.rtc
  • /more/more3.src
  • /more/otherstuff.txt
  • /grapes/oranges/carrots.src

Allow me to copy all *.src files to the container, putting them into the folders they came from:

  • /test/test1.src
  • /more/more3.src
  • /grapes/oranges/carrots.src

This would be SO useful for making layers of .net applications. (It would let me pull out all the .csproj files and restore them before I do the compile.)

4 Likes

This is old suggestion butI think is indeed needed.
We build .net core projects using Docker. We have a deep tree of folders with dependent projects.
So in order to utilize docker caching mechanism we separate dotnet restore phase. For it we need to only copy *.csproj files keeping folder structure. But we cannot do it with COPY **/*.csproj ./. We have to make separate instructions to copy all layers. For example,

COPY */*.csproj ./
COPY Folder1/*/*.csproj Folder1/
COPY Folder2/*/*.csproj Folder2/
COPY Folder2/InnerFolder1/*/*.csproj Folder2/InnderFolder1/

After that we run custom script to recreate folder structure and move copied files in respected folders. This is inconvenient.

Can it be solved?

1 Like