quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.78k stars 2.68k forks source link

AppCDS docs on usage with JIB are slightly misleading #43733

Closed DeMol-EE closed 3 weeks ago

DeMol-EE commented 1 month ago

In the documentation on AppCDS, it is stated that "simply setting quarkus.package.jar.appcds.enabled to true" is enough when using the quarkus-container-image-jib extension, but it is important to also set quarkus.package.jar.appcds.use-container to false (assuming that the choice for jib implies that docker is not available). Does anyone agree that it might be better to explicitly mention this?

quarkus-bot[bot] commented 1 month ago

/cc @geoand (jib)

geoand commented 3 weeks ago

Can you elaborate a little more on this?

Thanks

DeMol-EE commented 3 weeks ago

Sure. I was reading this blog post on project Leyden, which lead me to Quarkus’ AppCDS guide. There, I was reminded about jib. I remembered reading about it before on the container image guide but I had never given it much attention because I skipped straight to docker (which was familiar). After reading the blog post, I was excited about both technologies, especially because the AppCDS guide mentions that you practically get it for free in combination with jib. So, I set out on an undertaking to migrate all our services from docker to jib, and, in the process, also opt-in to AppCDS. As the AppCDS guide suggests, I added the flag -Dquarkus.package.jar.appcds.enabled=true to our maven build command, but was a little surprised by errors coming from AppCDS about the absence of a docker environment. I re-read both guides to see if I missed anything but didn’t find any clues until I started digging further online to discover the quarkus.package.jar.appcds.use-container flag. I had falsely assumed that, given that we were now also using jib, the default for this flag would be "false" (I figured this because I understood that one of the main points of using jib was to not need to have docker), but I was mostly surprised I hadn’t read about this flag in either guide. Don’t get me wrong, Quarkus still makes it child’s play to use jib and AppCDS; I merely wanted to suggest perhaps adding the "use-container" flag to either (or both) guides. What do you think?

geoand commented 3 weeks ago

Thanks a lot!

Your description is spot on (took me a while to remember how this works).

Would you like to enhance the documention along the lines of your proposal?

DeMol-EE commented 3 weeks ago

I could give it a go, sure, but now I’m wondering if it wouldn’t make more sense to change the default of the flag when it detects jib is used. Is that actually possible?

geoand commented 3 weeks ago

I'll have to look at it when I have some time

geoand commented 3 weeks ago

So IIUC, the machine on which you are building the container image does not have access to Docker?

In that case, setting quarkus.package.jar.appcds.use-container=false is indeed needed, however you need to make sure that the Java version used on that machine is exactly the same as the one used in the container image.

DeMol-EE commented 3 weeks ago

Indeed. So I suppose it isn't that trivial: jib can not just figure out which kind of image to build, this needs to be aligned with the Java version running the build, which could be anything. If this is working for me at this point in time, I guess I got lucky! However, does having a docker environment change much? Perhaps then the AppCDS plugin is smart enough to use a container image that matches the one from jib? Even so, doesn't it sort of defeat the purpose of jib, then? Though I suppose it is still nice not to have dockerfiles...

geoand commented 3 weeks ago

However, does having a docker environment change much?

What it allows us to do is pull the base image and use the Java version from it to run the AppCDS creation process locally.

Perhaps then the AppCDS plugin is smart enough to use a container image that matches the one from jib?

That is exactly what is happening.

Even so, doesn't it sort of defeat the purpose of jib, then? Though I suppose it is still nice not to have dockerfiles...

Jib does docker-less push, not build and that's only one of its selling points. But I do see your point.

DeMol-EE commented 3 weeks ago

Thanks for clearing that out. I need to take another look at our pipeline to ensure our AppCDS setup actually works. Perhaps I'll just add docker back to the environment (it's available anyway) and still stick to jib for the simplified setup. I'll see if I can free some time to prepare a PR with an extra sentence for the AppCDS guide mentioning the use-container flag, if that's still OK?

geoand commented 3 weeks ago

Definitely!

DeMol-EE commented 3 weeks ago

I’ve opened https://github.com/quarkusio/quarkus/pull/43946