Skip to content

Commit

Permalink
Merge pull request #21998 from zakkak/fix-17223
Browse files Browse the repository at this point in the history
Enforce order of arguments passed to native-image in container builds
  • Loading branch information
gsmet authored Dec 13, 2021
2 parents f65d72f + 9dcaafa commit 70c35b4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public abstract class NativeImageBuildContainerRunner extends NativeImageBuildRu

final NativeConfig nativeConfig;
protected final NativeConfig.ContainerRuntime containerRuntime;
private final String[] baseContainerRuntimeArgs;
String[] baseContainerRuntimeArgs;
protected final String outputPath;
private final String containerName;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import static io.quarkus.deployment.pkg.steps.LinuxIDUtil.getLinuxID;

import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

Expand All @@ -15,15 +17,8 @@ public class NativeImageBuildLocalContainerRunner extends NativeImageBuildContai

public NativeImageBuildLocalContainerRunner(NativeConfig nativeConfig, Path outputDir) {
super(nativeConfig, outputDir);
}

@Override
protected List<String> getContainerRuntimeBuildArgs() {
List<String> containerRuntimeArgs = super.getContainerRuntimeBuildArgs();
String volumeOutputPath = outputPath;
if (SystemUtils.IS_OS_WINDOWS) {
volumeOutputPath = FileUtil.translateToVolumePath(volumeOutputPath);
} else if (SystemUtils.IS_OS_LINUX) {
if (SystemUtils.IS_OS_LINUX) {
ArrayList<String> containerRuntimeArgs = new ArrayList<>(Arrays.asList(baseContainerRuntimeArgs));
String uid = getLinuxID("-ur");
String gid = getLinuxID("-gr");
if (uid != null && gid != null && !uid.isEmpty() && !gid.isEmpty()) {
Expand All @@ -33,6 +28,16 @@ protected List<String> getContainerRuntimeBuildArgs() {
containerRuntimeArgs.add("--userns=keep-id");
}
}
baseContainerRuntimeArgs = containerRuntimeArgs.toArray(baseContainerRuntimeArgs);
}
}

@Override
protected List<String> getContainerRuntimeBuildArgs() {
List<String> containerRuntimeArgs = super.getContainerRuntimeBuildArgs();
String volumeOutputPath = outputPath;
if (SystemUtils.IS_OS_WINDOWS) {
volumeOutputPath = FileUtil.translateToVolumePath(volumeOutputPath);
}

Collections.addAll(containerRuntimeArgs, "-v",
Expand Down

0 comments on commit 70c35b4

Please sign in to comment.