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

Introduce a new extension for generating Dockerfiles #42316

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

iocanel
Copy link
Contributor

@iocanel iocanel commented Aug 5, 2024

Updates:

  • Applied feedback from gsmet
  • Replaced String.format with Qute.fmt
  • dockerfiles command now forces quarkus-dockerfiles as dependency

@quarkus-bot quarkus-bot bot added the area/dependencies Pull requests that update a dependency file label Aug 5, 2024

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

@quarkus-bot quarkus-bot bot added area/devtools Issues/PR related to maven, gradle, platform and cli tooling/plugins area/documentation labels Aug 6, 2024

This comment has been minimized.

This comment has been minimized.

Copy link
Member

@gsmet gsmet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good over all, I spotted only micro issues.

Not sure who would have the time to test this one. @maxandersen do you have somebody in mind?

Comment on lines 48 to 83
<dependency>
<groupId>org.eclipse.aether</groupId>
<artifactId>aether-api</artifactId>
<version>1.1.0</version>
</dependency>
<dependency>
<groupId>org.eclipse.aether</groupId>
<artifactId>aether-impl</artifactId>
<version>1.1.0</version>
</dependency>
<dependency>
<groupId>org.eclipse.aether</groupId>
<artifactId>aether-spi</artifactId>
<version>1.1.0</version>
</dependency>
<dependency>
<groupId>org.eclipse.aether</groupId>
<artifactId>aether-connector-basic</artifactId>
<version>1.1.0</version>
</dependency>
<dependency>
<groupId>org.eclipse.aether</groupId>
<artifactId>aether-transport-file</artifactId>
<version>1.1.0</version>
</dependency>
<dependency>
<groupId>org.eclipse.aether</groupId>
<artifactId>aether-transport-http</artifactId>
<version>1.1.0</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The indentation is off here.

Comment on lines 13 to 26
static final String DEFAULT_JVM_FROM = "registry.access.redhat.com/ubi8/openjdk-21:1.19";
static final String DEFAULT_NATIVE_FROM = "registry.access.redhat.com/ubi8/ubi-minimal:8.9";

/**
* The from image to use for JVM based Dockerfiles
*/
@ConfigItem(defaultValue = "registry.access.redhat.com/ubi8/openjdk-21:1.19")
String jvmFrom;

/**
* The from image to use for native based Dockerfiles
*/
@ConfigItem(defaultValue = "registry.access.redhat.com/ubi8/ubi-minimal:8.9")
String nativeFrom;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not for this PR but we need to centralize all these images reference somewhere. We have them spread all over our code and it's a recipe for disaster.

I will create an issue about this so that we discuss it when @cescoffier is back.

metadata:
keywords:
- "dockerfiles"
guide: "https://quarkus.io/guides/dockerfiles"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please only reference a guide here when you have one or @holly-cummins will be unhappy :).

Comment on lines 74 to 109
<build>
<plugins>
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>build</goal>
<goal>generate-code</goal>
<goal>generate-code-tests</goal>
</goals>
<configuration>
<skipOriginalJarRename>true</skipOriginalJarRename>
<environmentVariables>
<MAVEN_REPO_LOCAL>${settings.localRepository}</MAVEN_REPO_LOCAL>
<GRADLE_OPTS>${env.MAVEN_OPTS}</GRADLE_OPTS>
</environmentVariables>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerArgs>
<arg>-parameters</arg>
</compilerArgs>
</configuration>
</plugin>
</plugins>
</build>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you indent that part with 4 spaces too.

And yes, we need an XML formatter...

@gsmet
Copy link
Member

gsmet commented Aug 9, 2024

Hey @iocanel . The feature freeze for 3.14 and 3.15 LTS is next Tuesday so we should really try to finalize this as it's an awesome feature.

Someone asked about it here #42441 and I was thinking of asking them to test but... we need instructions on how to install it as I don't think it comes by default?

Copy link
Member

@gsmet gsmet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added some additional comments that need fixing.

I saw you asked for a review by @maxandersen and @cescoffier anyway so I will let it there until they have time to review it.

Comment on lines 19 to 25
@ConfigItem(defaultValue = "registry.access.redhat.com/ubi8/openjdk-21:1.19")
String jvmFrom;

/**
* The from image to use for native based Dockerfiles
*/
@ConfigItem(defaultValue = "registry.access.redhat.com/ubi8/ubi-minimal:8.9")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, the constants should be used here.

@ConfigRoot
public class DockerfilesConfiguration {

static final String DEFAULT_JVM_FROM = "registry.access.redhat.com/ubi8/openjdk-21:1.19";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
static final String DEFAULT_JVM_FROM = "registry.access.redhat.com/ubi8/openjdk-21:1.19";
static final String DEFAULT_JVM_FROM = "registry.access.redhat.com/ubi8/openjdk-21:1.20";

public class DockerfilesConfiguration {

static final String DEFAULT_JVM_FROM = "registry.access.redhat.com/ubi8/openjdk-21:1.19";
static final String DEFAULT_NATIVE_FROM = "registry.access.redhat.com/ubi8/ubi-minimal:8.9";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
static final String DEFAULT_NATIVE_FROM = "registry.access.redhat.com/ubi8/ubi-minimal:8.9";
static final String DEFAULT_NATIVE_FROM = "registry.access.redhat.com/ubi8/ubi-minimal:8.10";

@gsmet
Copy link
Member

gsmet commented Aug 12, 2024

I'm also wondering if in the future we should generate the default Dockerfiles from there to be consistent.

@ia3andy
Copy link
Contributor

ia3andy commented Aug 20, 2024

@iocanel any reason not to continue on what you started with codestarts?

@ia3andy
Copy link
Contributor

ia3andy commented Aug 20, 2024

It should be possible to share the same templates as the existing codestarts and use a subset part of the codestart generator for generation.

Copy link
Member

@cescoffier cescoffier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I may have missed something but where extensions can add packages and files to the generated docker files?

So far I only see the "from" customization.

@iocanel
Copy link
Contributor Author

iocanel commented Sep 3, 2024

I may have missed something but where extensions can add packages and files to the generated docker files?

So far I only see the "from" customization.

What I had in my mind is to deal with just #41772 and leave the rest for future prs. If you feel that this needs to be done in one go, please let me know.

@quarkus-bot quarkus-bot bot added area/cli Related to quarkus cli (not maven/gradle/etc.) area/core labels Sep 30, 2024

This comment has been minimized.

Copy link

github-actions bot commented Oct 1, 2024

🎊 PR Preview 4cab5df has been successfully built and deployed to https://quarkus-pr-main-42316-preview.surge.sh/version/main/guides/

  • Images of blog posts older than 3 months are not available.
  • Newsletters older than 3 months are not available.

Copy link

quarkus-bot bot commented Oct 1, 2024

Status for workflow Quarkus Documentation CI

This is the status report for running Quarkus Documentation CI on commit 95984d7.

✅ The latest workflow run for the pull request has completed successfully.

It should be safe to merge provided you have a look at the other checks in the summary.

Warning

There are other workflow runs running, you probably need to wait for their status before merging.

Copy link

quarkus-bot bot commented Oct 1, 2024

Status for workflow Quarkus CI

This is the status report for running Quarkus CI on commit 95984d7.

✅ The latest workflow run for the pull request has completed successfully.

It should be safe to merge provided you have a look at the other checks in the summary.

You can consult the Develocity build scans.


Flaky tests - Develocity

⚙️ JVM Tests - JDK 21

📦 extensions/infinispan-cache/deployment

io.quarkus.cache.infinispan.InfinispanCacheTest.testGetAsyncWithParallelCalls - History

  • expected: "thread1" but was: "thread2" - org.opentest4j.AssertionFailedError
org.opentest4j.AssertionFailedError: 

expected: "thread1"
 but was: "thread2"
	at io.quarkus.cache.infinispan.InfinispanCacheTest.testGetAsyncWithParallelCalls(InfinispanCacheTest.java:283)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at io.quarkus.test.QuarkusUnitTest.runExtensionMethod(QuarkusUnitTest.java:513)
	at io.quarkus.test.QuarkusUnitTest.interceptTestMethod(QuarkusUnitTest.java:427)

@cescoffier
Copy link
Member

@iocanel Where are we on this?

@iocanel
Copy link
Contributor Author

iocanel commented Nov 11, 2024

@iocanel Where are we on this?
AFAIR, @gsmet and @ia3andy concerns have been addressed. So, we could possible or merge.

@@ -7,6 +7,9 @@
* This system property is used in rare by libraries (Truffle for example) to create their own ClassLoaders.
* The value of the system property is simply best effort, as there is no way to faithfully represent
* the Quarkus ClassLoader hierarchies in a system property value.
*
* @deprecated This was initially added to support Truffle, but it is no longer needed so the build item should not be used
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this part of this PR?

<plugins>
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my case it was a problem to have CLI be a quarkus app. Check you can build from scratch.

import picocli.CommandLine.Parameters;

@TopCommand
@Command(name = "dockerfiles", sortOptions = false, mixinStandardHelpOptions = false, header = "Generate Dockerfiles.", headerHeading = "%n", commandListHeading = "%nCommands:%n", synopsisHeading = "%nUsage: ", optionListHeading = "%nOptions:%n")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@Command(name = "dockerfiles", sortOptions = false, mixinStandardHelpOptions = false, header = "Generate Dockerfiles.", headerHeading = "%n", commandListHeading = "%nCommands:%n", synopsisHeading = "%nUsage: ", optionListHeading = "%nOptions:%n")
@Command(name = "dockerfiles", sortOptions = false, mixinStandardHelpOptions = false, header = "Generate Dockerfiles/Containerfiles.", headerHeading = "%n", commandListHeading = "%nCommands:%n", synopsisHeading = "%nUsage: ", optionListHeading = "%nOptions:%n")

@Option(names = { "--native" }, paramLabel = "", order = 5, description = "Flag to enable Native Dockerfile generation")
boolean generateNativeDockerfile;

@Parameters(arity = "0..1", paramLabel = "GENERATION_PATH", description = " The path to generate Dockerfiles")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@Parameters(arity = "0..1", paramLabel = "GENERATION_PATH", description = " The path to generate Dockerfiles")
@Parameters(arity = "0..1", paramLabel = "GENERATION_PATH", description = "The path to generate Dockerfiles")

private static final ArtifactDependency QUARKUS_DOCKERFILES_SPI = new ArtifactDependency("io.quarkus",
"quarkus-dockerfiles-spi", null, "jar", Dockerfiles.getVersion());

@Option(names = { "--jvm" }, paramLabel = "", order = 5, description = "Flag to enable JVM Dockerfile generation")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it generate all the variants or a single one (in this case, which one?)

@cescoffier
Copy link
Member

@iocanel ping.

@iocanel
Copy link
Contributor Author

iocanel commented Dec 2, 2024

I'll get back to it this week

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/cli Related to quarkus cli (not maven/gradle/etc.) area/core area/dependencies Pull requests that update a dependency file area/devtools Issues/PR related to maven, gradle, platform and cli tooling/plugins area/documentation triage/flaky-test
Projects
Status: Review pending
5 participants