Skip to content

Commit

Permalink
Fix wrong volume host path being used on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
w0pp authored Mar 3, 2024
1 parent 2fa75a1 commit a807eb5
Showing 1 changed file with 4 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,12 @@ private Volumes() {
public static void addVolumes(GenericContainer<?> container, Map<String, String> volumes) {
for (Map.Entry<String, String> volume : volumes.entrySet()) {
String hostLocation = volume.getKey();
BindMode bindMode = BindMode.READ_WRITE;
if (volume.getKey().startsWith(CLASSPATH)) {
URL url = Thread.currentThread().getContextClassLoader()
.getResource(hostLocation.replaceFirst(CLASSPATH, EMPTY));
if (url == null) {
throw new IllegalStateException("Classpath resource at '" + hostLocation + "' not found!");
}

hostLocation = url.getPath();
bindMode = BindMode.READ_ONLY;
container.withClasspathResourceMapping(hostLocation.replaceFirst(CLASSPATH, EMPTY), volume.getValue(),
BindMode.READ_ONLY);
} else {
container.withFileSystemBind(hostLocation, volume.getValue(), BindMode.READ_WRITE);
}

container.withFileSystemBind(hostLocation, volume.getValue(), bindMode);
}
}
}

0 comments on commit a807eb5

Please sign in to comment.