Skip to content

Commit

Permalink
Fix AppCDS generation when using podman
Browse files Browse the repository at this point in the history
We use the same trick as used in native-image
building

Fixes: #38616
(cherry picked from commit 692a640)
  • Loading branch information
geoand authored and gsmet committed Feb 7, 2024
1 parent 2cbfb67 commit 6623f88
Showing 1 changed file with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,18 @@ private List<String> dockerRunCommands(OutputTargetBuildItem outputTarget, Strin
command.add(outputTarget.getOutputDirectory().toAbsolutePath().toString() + ":" + CONTAINER_IMAGE_BASE_BUILD_DIR
+ ":z");
if (SystemUtils.IS_OS_LINUX) {
String uid = getLinuxID("-ur");
String gid = getLinuxID("-gr");
if (uid != null && gid != null && !uid.isEmpty() && !gid.isEmpty()) {
command.add("--user");
command.add(uid + ":" + gid);
if (containerRuntime.isDocker() && containerRuntime.isRootless()) {
Collections.addAll(command, "--user", String.valueOf(0));
} else {
String uid = getLinuxID("-ur");
String gid = getLinuxID("-gr");
if (uid != null && gid != null && !uid.isEmpty() && !gid.isEmpty()) {
Collections.addAll(command, "--user", uid + ":" + gid);
if (containerRuntime.isPodman() && containerRuntime.isRootless()) {
// Needed to avoid AccessDeniedExceptions
command.add("--userns=keep-id");
}
}
}
}
command.add("-w");
Expand Down

0 comments on commit 6623f88

Please sign in to comment.