Skip to content

Commit 3072be5

Browse files
authored
fix: modify default entrypoint for WAR containerization to be compatible with Jetty 12+ (#4216)
* fix: modify default entrypoint for WAR containerization to be compatible with Jetty 12+
1 parent 1488874 commit 3072be5

File tree

9 files changed

+17
-10
lines changed

9 files changed

+17
-10
lines changed

docs/faq.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -901,7 +901,7 @@ The `war` command currently supports containerization of standard WARs. It uses
901901
* Resources Layer
902902
* Classes Layer
903903

904-
The default entrypoint when using a jetty base image will be `java -jar /usr/local/jetty/start.jar` unless you choose to specify a custom one.
904+
The default entrypoint when using a jetty base image will be `java -jar /usr/local/jetty/start.jar --module=ee10-deploy` unless you choose to specify a custom one.
905905

906906
You can use a different Servlet engine base image with the help of the `--from` option and customize `--app-root`, `--entrypoint` and `--program-args`. If you don't set the `entrypoint` or `program-arguments`, Jib will inherit them from the base image. However, setting the `--app-root` is **required** if you use a non-jetty base image. Here is how the `war` command may look if you're using a Tomcat image:
907907
```

jib-cli/CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ All notable changes to this project will be documented in this file.
88
### Changed
99

1010
### Fixed
11+
- fix: support parsing manifest JSON containing `LayerSources:` from latest Docker. ([#4171](https://github.com/GoogleContainerTools/jib/pull/4171))
12+
- fix: (WAR Containerization) modify default entrypoint to `java -jar /usr/local/jetty/start.jar --module=ee10-deploy` for Jetty 12+ compatibility ([#4216](https://github.com/GoogleContainerTools/jib/pull/4216))
1113

1214
## 0.12.0
1315

jib-cli/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ This command follows the following pattern:
190190

191191
## Quickstart
192192

193-
1. Have your sample WAR ready and use the `war` command to containerize your WAR. By default, the WAR command uses [`jetty`](https://hub.docker.com/_/jetty) as the base image so the entrypoint is set to `java -jar /usr/local/jetty/start.jar`:
193+
1. Have your sample WAR ready and use the `war` command to containerize your WAR. By default, the WAR command uses [`jetty`](https://hub.docker.com/_/jetty) as the base image so the entrypoint is set to `java -jar /usr/local/jetty/start.jar --module=ee10-deploy`:
194194
```
195195
$ jib war --target=docker://cli-war-quickstart <your-sample>.war
196196
```

jib-cli/src/main/java/com/google/cloud/tools/jib/cli/war/WarFiles.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,10 @@ private static List<String> computeEntrypoint(
8181
return entrypoint;
8282
}
8383
if (commonContainerConfigCliOptions.isJettyBaseimage()) {
84-
return ImmutableList.of("java", "-jar", "/usr/local/jetty/start.jar");
84+
// Since we are using Jetty 12 or later as the default, the deploy module needs to be
85+
// specified. See
86+
// https://eclipse.dev/jetty/documentation/jetty-12/operations-guide/index.html
87+
return ImmutableList.of("java", "-jar", "/usr/local/jetty/start.jar", "--module=ee10-deploy");
8588
}
8689
return null;
8790
}

jib-cli/src/test/java/com/google/cloud/tools/jib/cli/war/WarFilesTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public void testToJibContainerBuilder_explodedStandard_basicInfo()
7474

7575
assertThat(buildPlan.getBaseImage()).isEqualTo("jetty");
7676
assertThat(buildPlan.getEntrypoint())
77-
.containsExactly("java", "-jar", "/usr/local/jetty/start.jar")
77+
.containsExactly("java", "-jar", "/usr/local/jetty/start.jar", "--module=ee10-deploy")
7878
.inOrder();
7979
assertThat(buildPlan.getLayers()).hasSize(1);
8080
assertThat(buildPlan.getLayers().get(0).getName()).isEqualTo("classes");

jib-gradle-plugin/CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ All notable changes to this project will be documented in this file.
1111

1212
### Fixed
1313
- fix: image builds should become reproducible once again ([#4204](https://github.com/GoogleContainerTools/jib/pull/4204))
14-
14+
- fix: (WAR Containerization) modify default entrypoint to `java -jar /usr/local/jetty/start.jar --module=ee10-deploy` for Jetty 12+ compatibility ([#4216](https://github.com/GoogleContainerTools/jib/pull/4216))
1515

1616
## 3.4.1
1717

jib-maven-plugin/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ All notable changes to this project will be documented in this file.
1111

1212
### Fixed
1313
- fix: image builds should become reproducible once again ([#4204](https://github.com/GoogleContainerTools/jib/pull/4204))
14+
- fix: (WAR Containerization) modify default entrypoint to `java -jar /usr/local/jetty/start.jar --module=ee10-deploy` for Jetty 12+ compatibility ([#4216](https://github.com/GoogleContainerTools/jib/pull/4216))
1415

1516
## 3.4.1
1617

jib-plugins-common/src/main/java/com/google/cloud/tools/jib/plugins/common/PluginConfigurationProcessor.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,8 @@ static JavaContainerBuilder getJavaContainerBuilderWithBaseImage(
569569
* <li>null (inheriting from the base image), if the user specified value is {@code INHERIT}
570570
* <li>the user specified one, if set
571571
* <li>for a WAR project, null (inheriting) if a custom base image is specified, and {@code
572-
* ["java", "-jar", "/usr/local/jetty/start.jar"]} otherwise (default Jetty base image)
572+
* ["java", "-jar", "/usr/local/jetty/start.jar", "--module=ee10-deploy"]} otherwise
573+
* (default Jetty base image)
573574
* <li>for a non-WAR project, by resolving the main class
574575
* </ol>
575576
*
@@ -622,7 +623,7 @@ static List<String> computeEntrypoint(
622623
}
623624
return rawConfiguration.getFromImage().isPresent()
624625
? null // Inherit if a custom base image.
625-
: Arrays.asList("java", "-jar", "/usr/local/jetty/start.jar");
626+
: Arrays.asList("java", "-jar", "/usr/local/jetty/start.jar", "--module=ee10-deploy");
626627
}
627628

628629
List<String> classpath = new ArrayList<>(rawExtraClasspath);

jib-plugins-common/src/test/java/com/google/cloud/tools/jib/plugins/common/PluginConfigurationProcessorTest.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ public void testEntrypoint_defaultWarPackaging()
474474
ContainerBuildPlan buildPlan = processCommonConfiguration();
475475

476476
assertThat(buildPlan.getEntrypoint())
477-
.containsExactly("java", "-jar", "/usr/local/jetty/start.jar")
477+
.containsExactly("java", "-jar", "/usr/local/jetty/start.jar", "--module=ee10-deploy")
478478
.inOrder();
479479
verifyNoInteractions(logger);
480480
}
@@ -704,7 +704,7 @@ public void testEntrypoint_warningOnMainclassForWar()
704704
ContainerBuildPlan buildPlan = processCommonConfiguration();
705705

706706
assertThat(buildPlan.getEntrypoint())
707-
.containsExactly("java", "-jar", "/usr/local/jetty/start.jar")
707+
.containsExactly("java", "-jar", "/usr/local/jetty/start.jar", "--module=ee10-deploy")
708708
.inOrder();
709709
verify(projectProperties)
710710
.log(
@@ -726,7 +726,7 @@ public void testEntrypoint_warningOnExpandClasspathDependenciesForWar()
726726
ContainerBuildPlan buildPlan = processCommonConfiguration();
727727

728728
assertThat(buildPlan.getEntrypoint())
729-
.containsExactly("java", "-jar", "/usr/local/jetty/start.jar")
729+
.containsExactly("java", "-jar", "/usr/local/jetty/start.jar", "--module=ee10-deploy")
730730
.inOrder();
731731
verify(projectProperties)
732732
.log(

0 commit comments

Comments
 (0)