-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
Environment: IntelliJ IDEA 2020.2 EAP Build #IU-202.5103.13 with bundled Docker plugin 202.5103.13. Docker plugin must use docker-java, connection to Docker Desktop for Windows via npipe. Cannot find out the exact version of docker-java that is used.
Given the following minimal project setup:
node_modules with +67k files
Dockerfile with single line FROM hello-world
.dockerignore with single line node_modules
Then, run docker build . in the root directory.
Expected behaviour: The image is built instantly, because build context contains only the Dockerfile (large node_modules directory is ignored), and there are almost no instructions in the Dockerfile itself.
Observed behaviour: For +30 seconds, the screen shows "Building image..." , and after that only one file is added to the build context archive.
I assume, the build traverses all +67k files in the node_modules directory, only to find none of them have to be included. This would be very inefficient. When there are no exceptions, that allow a file below node_modules, it might skip the whole directory.
Update:
Unit test in docker-java-core, testdir has the large folder as child, .dockerignore absent:
@Test
public void can_parse_dockerfile() throws IOException {
File dockerFile = new File(".\\testdir\\Dockerfile");
File baseDirectory = new File(".\\testdir");
Dockerfile dockerfile = new Dockerfile(dockerFile, baseDirectory);
Stopwatch stopwatch = Stopwatch.createStarted();
Dockerfile.ScannedResult parse = dockerfile.parse();
System.out.println("Parse took " + stopwatch.elapsed(TimeUnit.MILLISECONDS) + "ms");
System.out.println(parse.filesToAdd.size() + " files added");
}Output:
Parse took 28008ms
4 files added