Skip to content

Commit

Permalink
Fix dockerfile setup resources (#940)
Browse files Browse the repository at this point in the history
Use lazy evaluation of the layers' files to avoid triggering
dependency resolution during configuration.
  • Loading branch information
rorueda authored Feb 7, 2024
1 parent 4b23642 commit a2409ff
Showing 1 changed file with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -221,16 +221,17 @@ private String getProjectFnVersion() {
}

public static void setupResources(Dockerfile task, List<Layer> layers, String workDir) {
if (workDir == null) {
workDir = determineWorkingDir(task);
}
task.workingDir(workDir);
final String finalWorkDir = workDir != null ? workDir : determineWorkingDir(task);
task.workingDir(finalWorkDir);

for (Layer layer : layers) {
var files = layer.getFiles();
if (!files.isEmpty()) {
task.copyFile(task.getProject().provider(() -> {
if (layer.getFiles().isEmpty()) {
return null;
}
var kind = layer.getLayerKind().get();
task.copyFile("layers/" + kind.sourceDirName(), workDir + "/" + kind.targetDirName());
}
return new CopyFile("layers/" + kind.sourceDirName(), finalWorkDir + "/" + kind.targetDirName());
}));
}
}

Expand Down

0 comments on commit a2409ff

Please sign in to comment.