This is an automated email from the ASF dual-hosted git repository. astefanutti pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit 41b7ccf902c4bebcce33fa667aa0dce7f9385940 Author: Antonin Stefanutti <anto...@stefanutti.fr> AuthorDate: Thu Jul 29 11:34:06 2021 +0200 feat: Switch on Quarkus native build --- build/Dockerfile | 7 ++++--- pkg/builder/image.go | 13 +++++++++++++ pkg/builder/quarkus.go | 3 ++- pkg/trait/jvm.go | 6 +++--- 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/build/Dockerfile b/build/Dockerfile index 3bfc57c..1f3e2ac 100644 --- a/build/Dockerfile +++ b/build/Dockerfile @@ -13,12 +13,15 @@ # See the License for the specific language governing permissions and # limitations under the License. -FROM adoptopenjdk/openjdk11:slim +FROM quay.io/quarkus/ubi-quarkus-native-image:21.1.0-java11 +#FROM quay.io/quarkus/ubi-quarkus-mandrel:21.2.0.0-Final-java11 ARG MAVEN_VERSION="3.6.3" ARG SHA="c35a1803a6e70a126e80b2b3ae33eed961f83ed74d18fcd16909b2d44d7dada3203f1ffe726c17ef8dcca2dcaa9fca676987befeadc9b9f759967a8cb77181c0" ARG BASE_URL="https://apache.osuosl.org/maven/maven-3/${MAVEN_VERSION}/binaries" +USER 0 + RUN mkdir -p /usr/share/maven \ && curl -Lso /tmp/maven.tar.gz ${BASE_URL}/apache-maven-${MAVEN_VERSION}-bin.tar.gz \ && echo "${SHA} /tmp/maven.tar.gz" | sha512sum -c - \ @@ -34,8 +37,6 @@ ADD build/logback.xml /usr/share/maven/conf/ ENV MAVEN_OPTS="${MAVEN_OPTS} -Dlogback.configurationFile=/usr/share/maven/conf/logback.xml" -USER 0 - RUN chgrp -R 0 /tmp/artifacts/m2 \ && chmod -R g=u /tmp/artifacts/m2 \ && chgrp -R 0 /kamelets \ diff --git a/pkg/builder/image.go b/pkg/builder/image.go index ce01bff..b4f02c2 100644 --- a/pkg/builder/image.go +++ b/pkg/builder/image.go @@ -29,6 +29,7 @@ import ( "github.com/apache/camel-k/pkg/platform" "github.com/apache/camel-k/pkg/util" "github.com/apache/camel-k/pkg/util/controller" + "github.com/apache/camel-k/pkg/util/defaults" ) const ( @@ -111,10 +112,22 @@ func imageContext(ctx *builderContext, selector artifactsSelector) error { } } + runner := "camel-k-integration-" + defaults.Version + "-runner" + _, err = util.CopyFile(path.Join(ctx.Path, "maven", "target", runner), path.Join(contextDir, runner)) + if err != nil { + return err + } + // #nosec G202 dockerfile := []byte(` FROM ` + ctx.BaseImage + ` ADD . ` + DeploymentDir + ` + + RUN chmod 775 ` + DeploymentDir + ` ` + DeploymentDir + `/` + runner + ` \ + && chown -R 1000 ` + DeploymentDir + ` \ + && chmod -R "g+rwX" ` + DeploymentDir + ` \ + && chown -R 1000:root ` + DeploymentDir + ` + USER 1000 `) diff --git a/pkg/builder/quarkus.go b/pkg/builder/quarkus.go index 6bdfecb..3757af3 100644 --- a/pkg/builder/quarkus.go +++ b/pkg/builder/quarkus.go @@ -109,7 +109,8 @@ func GenerateQuarkusProjectCommon(camelQuarkusVersion string, runtimeVersion str p.Properties["quarkus.banner.enabled"] = "false" // set fast-jar packaging since it gives some startup time improvements - p.Properties["quarkus.package.type"] = "fast-jar" + p.Properties["quarkus.package.type"] = "native" + // p.Properties["quarkus.native.additional-build-args"] = "--language:js" // DependencyManagement p.DependencyManagement.Dependencies = append(p.DependencyManagement.Dependencies, diff --git a/pkg/trait/jvm.go b/pkg/trait/jvm.go index b31bca6..c6a4b2b 100644 --- a/pkg/trait/jvm.go +++ b/pkg/trait/jvm.go @@ -37,6 +37,7 @@ import ( v1 "github.com/apache/camel-k/pkg/apis/camel/v1" "github.com/apache/camel-k/pkg/builder" "github.com/apache/camel-k/pkg/util" + "github.com/apache/camel-k/pkg/util/defaults" ) // The JVM trait is used to configure the JVM that runs the integration. @@ -185,13 +186,12 @@ func (t *jvmTrait) Apply(e *Environment) error { args = append(args, e.CamelCatalog.Runtime.ApplicationClass) if IsNilOrTrue(t.PrintCommand) { - args = append([]string{"exec", "java"}, args...) + args = []string{"exec", "./camel-k-integration-" + defaults.Version + "-runner"} container.Command = []string{"/bin/sh", "-c"} cmd := strings.Join(args, " ") container.Args = []string{"echo " + cmd + " && " + cmd} } else { - container.Command = []string{"java"} - container.Args = args + container.Command = []string{"./camel-k-integration-" + defaults.Version + "-runner"} } container.WorkingDir = builder.DeploymentDir