-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Take into account "fallback to container" when determining where nati…
…ve-image gets executed Sometimes we need to do things differently based on whether the native build happens within a container or not. Before this patch, we used to determine that based exclusively on explicit configuration. After this patch, we correctly take into account that we sometimes need to "fall back" to containers even though the configuration didn't mention anything about containers, simply because native-image isn't installed. The previous behavior used to lead to at least one bug: when debugging GraalVM's JVM, we determined the address to bind to based on whether we're running in a container or not, and [here we used to make the wrong choice](https://github.com/quarkusio/quarkus/blob/635a848bb8022e4ca6e945af7e62edc32a288588/core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/NativeImageBuildStep.java#L780-L784), resulting in the JVM debug agent being inaccessible from the Docker host. See also https://quarkusio.zulipchat.com/#narrow/stream/187038-dev/topic/quarkus.2Enative.2Edebug-build-process/near/345399379 Co-Authored-By: Foivos Zakkak <fzakkak@redhat.com>
- Loading branch information
Showing
14 changed files
with
182 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
...loyment/src/main/java/io/quarkus/deployment/pkg/builditem/NativeImageRunnerBuildItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package io.quarkus.deployment.pkg.builditem; | ||
|
||
import io.quarkus.builder.item.SimpleBuildItem; | ||
import io.quarkus.deployment.pkg.steps.NativeImageBuildRunner; | ||
|
||
/** | ||
* The resolved factory for the native image runner. | ||
*/ | ||
public final class NativeImageRunnerBuildItem extends SimpleBuildItem { | ||
private final NativeImageBuildRunner buildRunner; | ||
|
||
public NativeImageRunnerBuildItem(NativeImageBuildRunner buildRunner) { | ||
this.buildRunner = buildRunner; | ||
} | ||
|
||
public NativeImageBuildRunner getBuildRunner() { | ||
return buildRunner; | ||
} | ||
|
||
public boolean isContainerBuild() { | ||
return buildRunner.isContainer(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
...deployment/src/main/java/io/quarkus/deployment/pkg/steps/NativeImageBuildRunnerError.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package io.quarkus.deployment.pkg.steps; | ||
|
||
import java.nio.file.Path; | ||
import java.util.List; | ||
|
||
public class NativeImageBuildRunnerError extends NativeImageBuildRunner { | ||
|
||
private String message; | ||
|
||
public NativeImageBuildRunnerError(String message) { | ||
this.message = message; | ||
} | ||
|
||
@Override | ||
public boolean isContainer() { | ||
return false; | ||
} | ||
|
||
@Override | ||
protected String[] getGraalVMVersionCommand(List<String> args) { | ||
throw new RuntimeException(message); | ||
} | ||
|
||
@Override | ||
protected String[] getBuildCommand(Path outputDir, List<String> args) { | ||
throw new RuntimeException(message); | ||
} | ||
|
||
@Override | ||
protected void objcopy(Path outputDir, String... args) { | ||
throw new RuntimeException(message); | ||
} | ||
} |
Oops, something went wrong.