Skip to content

Commit

Permalink
fix: modify default entrypoint for WAR containerization to be compati…
Browse files Browse the repository at this point in the history
…ble with Jetty 12+ (#4216)

* fix: modify default entrypoint for WAR containerization to be compatible with Jetty 12+
  • Loading branch information
mpeddada1 authored Mar 26, 2024
1 parent 1488874 commit 3072be5
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion docs/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -901,7 +901,7 @@ The `war` command currently supports containerization of standard WARs. It uses
* Resources Layer
* Classes Layer

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.
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.

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:
```
Expand Down
2 changes: 2 additions & 0 deletions jib-cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ All notable changes to this project will be documented in this file.
### Changed

### Fixed
- fix: support parsing manifest JSON containing `LayerSources:` from latest Docker. ([#4171](/~https://github.com/GoogleContainerTools/jib/pull/4171))
- 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))

## 0.12.0

Expand Down
2 changes: 1 addition & 1 deletion jib-cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ This command follows the following pattern:

## Quickstart

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`:
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`:
```
$ jib war --target=docker://cli-war-quickstart <your-sample>.war
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@ private static List<String> computeEntrypoint(
return entrypoint;
}
if (commonContainerConfigCliOptions.isJettyBaseimage()) {
return ImmutableList.of("java", "-jar", "/usr/local/jetty/start.jar");
// Since we are using Jetty 12 or later as the default, the deploy module needs to be
// specified. See
// https://eclipse.dev/jetty/documentation/jetty-12/operations-guide/index.html
return ImmutableList.of("java", "-jar", "/usr/local/jetty/start.jar", "--module=ee10-deploy");
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public void testToJibContainerBuilder_explodedStandard_basicInfo()

assertThat(buildPlan.getBaseImage()).isEqualTo("jetty");
assertThat(buildPlan.getEntrypoint())
.containsExactly("java", "-jar", "/usr/local/jetty/start.jar")
.containsExactly("java", "-jar", "/usr/local/jetty/start.jar", "--module=ee10-deploy")
.inOrder();
assertThat(buildPlan.getLayers()).hasSize(1);
assertThat(buildPlan.getLayers().get(0).getName()).isEqualTo("classes");
Expand Down
2 changes: 1 addition & 1 deletion jib-gradle-plugin/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ All notable changes to this project will be documented in this file.

### Fixed
- fix: image builds should become reproducible once again ([#4204](/~https://github.com/GoogleContainerTools/jib/pull/4204))

- 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))

## 3.4.1

Expand Down
1 change: 1 addition & 0 deletions jib-maven-plugin/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ All notable changes to this project will be documented in this file.

### Fixed
- fix: image builds should become reproducible once again ([#4204](/~https://github.com/GoogleContainerTools/jib/pull/4204))
- 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))

## 3.4.1

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,8 @@ static JavaContainerBuilder getJavaContainerBuilderWithBaseImage(
* <li>null (inheriting from the base image), if the user specified value is {@code INHERIT}
* <li>the user specified one, if set
* <li>for a WAR project, null (inheriting) if a custom base image is specified, and {@code
* ["java", "-jar", "/usr/local/jetty/start.jar"]} otherwise (default Jetty base image)
* ["java", "-jar", "/usr/local/jetty/start.jar", "--module=ee10-deploy"]} otherwise
* (default Jetty base image)
* <li>for a non-WAR project, by resolving the main class
* </ol>
*
Expand Down Expand Up @@ -622,7 +623,7 @@ static List<String> computeEntrypoint(
}
return rawConfiguration.getFromImage().isPresent()
? null // Inherit if a custom base image.
: Arrays.asList("java", "-jar", "/usr/local/jetty/start.jar");
: Arrays.asList("java", "-jar", "/usr/local/jetty/start.jar", "--module=ee10-deploy");
}

List<String> classpath = new ArrayList<>(rawExtraClasspath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ public void testEntrypoint_defaultWarPackaging()
ContainerBuildPlan buildPlan = processCommonConfiguration();

assertThat(buildPlan.getEntrypoint())
.containsExactly("java", "-jar", "/usr/local/jetty/start.jar")
.containsExactly("java", "-jar", "/usr/local/jetty/start.jar", "--module=ee10-deploy")
.inOrder();
verifyNoInteractions(logger);
}
Expand Down Expand Up @@ -704,7 +704,7 @@ public void testEntrypoint_warningOnMainclassForWar()
ContainerBuildPlan buildPlan = processCommonConfiguration();

assertThat(buildPlan.getEntrypoint())
.containsExactly("java", "-jar", "/usr/local/jetty/start.jar")
.containsExactly("java", "-jar", "/usr/local/jetty/start.jar", "--module=ee10-deploy")
.inOrder();
verify(projectProperties)
.log(
Expand All @@ -726,7 +726,7 @@ public void testEntrypoint_warningOnExpandClasspathDependenciesForWar()
ContainerBuildPlan buildPlan = processCommonConfiguration();

assertThat(buildPlan.getEntrypoint())
.containsExactly("java", "-jar", "/usr/local/jetty/start.jar")
.containsExactly("java", "-jar", "/usr/local/jetty/start.jar", "--module=ee10-deploy")
.inOrder();
verify(projectProperties)
.log(
Expand Down

0 comments on commit 3072be5

Please sign in to comment.