diff --git a/extensions/container-image/container-image-jib/deployment/src/main/java/io/quarkus/container/image/jib/deployment/JibConfig.java b/extensions/container-image/container-image-jib/deployment/src/main/java/io/quarkus/container/image/jib/deployment/JibConfig.java
index 876665d5938a8d..c7ce9311e43e84 100644
--- a/extensions/container-image/container-image-jib/deployment/src/main/java/io/quarkus/container/image/jib/deployment/JibConfig.java
+++ b/extensions/container-image/container-image-jib/deployment/src/main/java/io/quarkus/container/image/jib/deployment/JibConfig.java
@@ -54,6 +54,8 @@ public class JibConfig {
* If this is set, then it will be used as the entry point of the container image.
* There are a few things to be aware of when creating an entry point
*
+ * - Entrypoint "INHERIT" means to inherit entrypoint from base image, {@code jvmArguments} field is used for
+ * arguments
* - A valid entrypoint is jar package specific (see {@code quarkus.package.type})
* - A valid entrypoint depends on the location of both the launching scripts and the application jar file. To that
* end it's helpful to remember that when {@code fast-jar} packaging is used (the default), all necessary application
@@ -62,7 +64,7 @@ public class JibConfig {
* jars
* are unpacked under the {@code /app} directory
* and that directory is used as the working directory.
- * - Even if the {@code jvmArguments} field is set, it is ignored completely
+ * - Even if the {@code jvmArguments} field is set, it is ignored completely unless entrypoint is "INHERIT"
*
*
* When this is not set, a proper default entrypoint will be constructed.
@@ -77,10 +79,12 @@ public class JibConfig {
* If this is set, then it will be used as the entry point of the container image.
* There are a few things to be aware of when creating an entry point
*
+ * - Entrypoint "INHERIT" means to inherit entrypoint from base image, {@code nativeArguments} field is used for
+ * arguments
* - A valid entrypoint depends on the location of both the launching scripts and the native binary file. To that end
* it's helpful to remember that the native application is added to the {@code /work} directory and that and the same
* directory is also used as the working directory
- * - Even if the {@code nativeArguments} field is set, it is ignored completely
+ * - Even if the {@code nativeArguments} field is set, it is ignored completely unless entrypoint is "INHERIT"
*
*
* When this is not set, a proper default entrypoint will be constructed.
diff --git a/extensions/container-image/container-image-jib/deployment/src/main/java/io/quarkus/container/image/jib/deployment/JibProcessor.java b/extensions/container-image/container-image-jib/deployment/src/main/java/io/quarkus/container/image/jib/deployment/JibProcessor.java
index 6b0ebe0ddb21fa..b2a716c6a2dd8d 100644
--- a/extensions/container-image/container-image-jib/deployment/src/main/java/io/quarkus/container/image/jib/deployment/JibProcessor.java
+++ b/extensions/container-image/container-image-jib/deployment/src/main/java/io/quarkus/container/image/jib/deployment/JibProcessor.java
@@ -562,6 +562,8 @@ private JibContainerBuilder createContainerBuilderFromFastJar(String baseJvmImag
.setEnvironment(getEnvironmentVariables(jibConfig))
.setLabels(allLabels(jibConfig, containerImageConfig, containerImageLabels));
+ mayInheritEntrypoint(jibContainerBuilder, entrypoint, jibConfig.jvmArguments);
+
if (jibConfig.useCurrentTimestamp) {
jibContainerBuilder.setCreationTime(now);
}
@@ -596,6 +598,15 @@ public JibContainerBuilder addLayer(JibContainerBuilder jibContainerBuilder, Lis
return jibContainerBuilder.addFileEntriesLayer(layerConfigurationBuilder.build());
}
+ private void mayInheritEntrypoint(JibContainerBuilder jibContainerBuilder, List entrypoint,
+ List arguments) {
+ if (entrypoint.size() == 1 && "INHERIT".equals(entrypoint.get(0))) {
+ jibContainerBuilder
+ .setEntrypoint((List) null)
+ .setProgramArguments(arguments);
+ }
+ }
+
private List determineEffectiveJvmArguments(JibConfig jibConfig, Optional appCDSResult) {
List effectiveJvmArguments = new ArrayList<>(jibConfig.jvmArguments);
jibConfig.jvmAdditionalArguments.ifPresent(effectiveJvmArguments::addAll);
@@ -666,6 +677,7 @@ private JibContainerBuilder createContainerBuilderFromLegacyJar(String baseJvmIm
if (jibConfig.jvmEntrypoint.isPresent()) {
jibContainerBuilder.setEntrypoint(jibConfig.jvmEntrypoint.get());
+ mayInheritEntrypoint(jibContainerBuilder, jibConfig.jvmEntrypoint.get(), jibConfig.jvmArguments);
}
return jibContainerBuilder;
@@ -702,6 +714,8 @@ private JibContainerBuilder createContainerBuilderFromNative(JibConfig jibConfig
.setEnvironment(getEnvironmentVariables(jibConfig))
.setLabels(allLabels(jibConfig, containerImageConfig, containerImageLabels));
+ mayInheritEntrypoint(jibContainerBuilder, entrypoint, jibConfig.nativeArguments.orElse(null));
+
if (jibConfig.useCurrentTimestamp) {
jibContainerBuilder.setCreationTime(Instant.now());
}
diff --git a/integration-tests/container-image/maven-invoker-way/src/it/container-build-jib-inherit/invoker.properties b/integration-tests/container-image/maven-invoker-way/src/it/container-build-jib-inherit/invoker.properties
new file mode 100644
index 00000000000000..5a1e6fd59b49cd
--- /dev/null
+++ b/integration-tests/container-image/maven-invoker-way/src/it/container-build-jib-inherit/invoker.properties
@@ -0,0 +1 @@
+invoker.goals=clean package -Dquarkus.container-image.build=true
diff --git a/integration-tests/container-image/maven-invoker-way/src/it/container-build-jib-inherit/pom.xml b/integration-tests/container-image/maven-invoker-way/src/it/container-build-jib-inherit/pom.xml
new file mode 100644
index 00000000000000..e3e1993602bb05
--- /dev/null
+++ b/integration-tests/container-image/maven-invoker-way/src/it/container-build-jib-inherit/pom.xml
@@ -0,0 +1,115 @@
+
+
+ 4.0.0
+ org.acme
+ container-build-jib-inherit
+ 0.1-SNAPSHOT
+
+ UTF-8
+ 3.0.0-M7
+ 11
+ UTF-8
+ 11
+
+
+
+
+ io.quarkus
+ quarkus-bom
+ @project.version@
+ pom
+ import
+
+
+
+
+
+ io.quarkus
+ quarkus-resteasy-reactive
+
+
+ io.quarkus
+ quarkus-container-image-jib
+
+
+ io.quarkus
+ quarkus-junit5
+ test
+
+
+ io.rest-assured
+ rest-assured
+ test
+
+
+
+
+
+ io.quarkus
+ quarkus-maven-plugin
+ @project.version@
+
+
+
+ build
+
+
+
+
+
+ maven-surefire-plugin
+ ${surefire-plugin.version}
+
+
+ org.jboss.logmanager.LogManager
+ ${maven.home}
+
+
+
+
+
+
+
+ native
+
+
+ native
+
+
+
+ native
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+
+ ${native.surefire.skip}
+
+
+
+ maven-failsafe-plugin
+ ${surefire-plugin.version}
+
+
+
+ integration-test
+ verify
+
+
+
+ ${project.build.directory}/${project.build.finalName}-runner
+ org.jboss.logmanager.LogManager
+ ${maven.home}
+
+
+
+
+
+
+
+
+
+
diff --git a/integration-tests/container-image/maven-invoker-way/src/it/container-build-jib-inherit/src/main/java/org/acme/Hello.java b/integration-tests/container-image/maven-invoker-way/src/it/container-build-jib-inherit/src/main/java/org/acme/Hello.java
new file mode 100644
index 00000000000000..ad80766a17747a
--- /dev/null
+++ b/integration-tests/container-image/maven-invoker-way/src/it/container-build-jib-inherit/src/main/java/org/acme/Hello.java
@@ -0,0 +1,16 @@
+package org.acme;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+@Path("/hello")
+public class Hello {
+
+ @GET
+ @Produces(MediaType.TEXT_PLAIN)
+ public String hello() {
+ return "hello";
+ }
+}
\ No newline at end of file
diff --git a/integration-tests/container-image/maven-invoker-way/src/it/container-build-jib-inherit/src/main/resources/application.properties b/integration-tests/container-image/maven-invoker-way/src/it/container-build-jib-inherit/src/main/resources/application.properties
new file mode 100644
index 00000000000000..0cac87da6ec2b3
--- /dev/null
+++ b/integration-tests/container-image/maven-invoker-way/src/it/container-build-jib-inherit/src/main/resources/application.properties
@@ -0,0 +1,8 @@
+# Configuration file
+# key = value
+quarkus.package.type=fast-jar
+quarkus.jib.jvm-arguments=java,-jar,/app/quarkus-run.jar
+quarkus.jib.jvm-entrypoint=INHERIT
+quarkus.jib.native-arguments=./application
+quarkus.jib.native-entrypoint=INHERIT
+quarkus.jib.working-directory=/app
diff --git a/integration-tests/container-image/maven-invoker-way/src/it/container-build-jib-inherit/verify.groovy b/integration-tests/container-image/maven-invoker-way/src/it/container-build-jib-inherit/verify.groovy
new file mode 100644
index 00000000000000..9997de49e3f8ca
--- /dev/null
+++ b/integration-tests/container-image/maven-invoker-way/src/it/container-build-jib-inherit/verify.groovy
@@ -0,0 +1,37 @@
+import io.quarkus.deployment.util.ExecUtil
+
+import java.util.concurrent.ThreadLocalRandom
+
+try {
+ ExecUtil.exec("docker", "version", "--format", "'{{.Server.Version}}'")
+} catch (Exception ignored) {
+ return
+}
+
+String image = "${System.getProperty("user.name")}/container-build-jib-inherit:0.1-SNAPSHOT"
+assert ExecUtil.exec("docker", "images", image)
+
+String containerName = "container-build-jib-inherit-" + ThreadLocalRandom.current().nextInt(10000)
+int maxTimesToCheck = 10
+int i = 0
+int hostPort = 12345
+assert ExecUtil.exec("docker", "run", "-d", "-p", "$hostPort:8080", "--name", containerName, image)
+
+while (true) {
+ try {
+ def response = "http://localhost:$hostPort/hello".toURL().text
+ assert response == "hello"
+ break
+ } catch (IOException e) {
+ try {
+ Thread.sleep(2000)
+ } catch (InterruptedException ignored) {
+ }
+ if ((i++) >= maxTimesToCheck) {
+ throw new RuntimeException("Unable to determine if container is running", e)
+ }
+ }
+}
+assert ExecUtil.exec("docker", "stop", containerName)
+assert ExecUtil.exec("docker", "rm", containerName)
+assert ExecUtil.exec("docker", "rmi", image)