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

Changing base jetty image for WAR: running image fails #3204

Closed
aanno opened this issue Apr 12, 2021 · 5 comments
Closed

Changing base jetty image for WAR: running image fails #3204

aanno opened this issue Apr 12, 2021 · 5 comments

Comments

@aanno
Copy link

aanno commented Apr 12, 2021

Environment:

  • Jib version: 3.0.0
  • Build tool: mvn 3.6.3
  • OS: Linux (Fedora 33)

Description of the issue:
Changing base jetty image for WAR: running image fails

Expected behavior:
Changing base jetty image for WAR: running image should run WAR on jetty

Steps to reproduce:

jib-maven-plugin Configuration:

			<plugin>
				<groupId>com.google.cloud.tools</groupId>
				<artifactId>jib-maven-plugin</artifactId>
				<version>3.0.0</version>
				<configuration>
					<from>
						<image>jetty:11.0.2-jre11</image>
					</from>
					<to>
						<image>matching-server-war-jetty</image>
					</to>
				</configuration>
				<executions>
					<execution>
						<phase>package</phase>
						<goals>
							<goal>build</goal>
						</goals>
					</execution>
				</executions>
			</plugin>

When using the maven configuration above:

$ podman run --rm -p 8080:8080 matching-server-war-jetty:latest 2>&1 | tee log
/docker-entrypoint.sh: 98: /docker-entrypoint.sh: cannot create /var/lib/jetty/jetty.start: Permission denied

When using the maven configuration above without the from part, everything works as expected.

@chanseokoh
Copy link
Member

chanseokoh commented Apr 12, 2021

Hi @aanno,

I know what's happening. The way we make the default jetty image (when you are not specifying <from>) works is to set the entrypoint to java -jar /usr/local/jetty/start.jar.

(from #3124)

For WAR projects, we no longer inherits the entrypoint from the base image. The new default entrypoint is explicitly set to java -jar /usr/local/jetty/start.jar. The idea is from #1270 (comment).

So I expect you should be able to resolve the issue by specifying

<configuration>
  ...
  <container>
    <entrypoint>java,-jar,/usr/local/jetty/start.jar</entrypoint>
  </container>
</configuration>

Maybe we can help this situation by setting this entrypoint automatically if the base image is from the official jetty repo and no entrypoint is given? Or, maybe we can just document how to configure this here?

@chanseokoh

This comment has been minimized.

@chanseokoh
Copy link
Member

Never mind. The error on my project was because my source was based on old Servlet API. I noticed that jetty:latest runs Jetty 9.4. OTOH, Jetty 11 (jetty:11.0.2-jre11) seems to require Servlet 5.0. When converted my source to Servlet 5.0, it works. So, yeah, set <entrypoint>java,-jar,/usr/local/jetty/start.jar</entrypoint>, and you should be good.

@chanseokoh
Copy link
Member

So #3205 documented an example to use jetty as a base image, in addition to the existing example to use tomcat.

I think this issue can be resolved with the documentation. Technically Jib could do more magic to automatically set multiple configurations (appRoot, entrypoint, etc.) for some well-known base images, but I don't think we want to enter into that territory and open Pandora's box. If the user specifies a custom Servlet engine, then our stance is that basically it's on their own to figure out how to properly use the image. However, we can help documentation and examples.

@aanno
Copy link
Author

aanno commented Apr 13, 2021

Dear @chanseokoh, thank you very much for prompt support!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants