I have a .dockerignore
file and I'm trying to allow Docker to upload only *.json
files but from any of subfolders.
For example, for the next files structure:
public/readme.md
public/subfolder/a.json
public/subfolder/b.json
public/other/c.json
public/other/file.txt
I'm expecting to see only json files in the image:
public/subfolder/a.json
public/subfolder/b.json
public/other/c.json
Of course they must be located in the same directories as in original source.
I tried several ways but didn't succeed.
UP: I don't know how many subfolders will be created in the public/
directory and how deep will be the directories structure.
I think you can achieve what you want by relying on one such .dockerignore:
The tricky thing is that the first line of this file is
public/*
but notpublic
nor*
(otherwise the!...
subsequent lines won't work).Note also that you may want to automate the generation of one such .dockerignore, to cope with possible tree structure changes.
For example:
$ ./gen-dockerignore.sh
would output the following file: