Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enforce order of arguments passed to native-image in container builds #21998

Merged
merged 1 commit into from
Dec 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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