Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ protected Integer export(Path exportBaseDir, ExportBaseCommand cmd) throws Excep
cmd.quarkusGroupId = this.quarkusGroupId;
cmd.quarkusArtifactId = this.quarkusArtifactId;
cmd.quarkusVersion = this.quarkusVersion;
cmd.quarkusPackageType = this.quarkusPackageType;
cmd.springBootVersion = this.springBootVersion;
cmd.mavenWrapper = this.mavenWrapper;
cmd.quiet = this.quiet;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,11 @@ public abstract class ExportBaseCommand extends CamelCommand {
defaultValue = RuntimeType.QUARKUS_VERSION)
protected String quarkusVersion = RuntimeType.QUARKUS_VERSION;

@CommandLine.Option(names = { "--quarkus-package-type" },
description = "Quarkus package type (uber-jar or fast-jar)",
defaultValue = "uber-jar")
protected String quarkusPackageType = "uber-jar";

@CommandLine.Option(names = { "--maven-wrapper" }, defaultValue = "true",
description = "Include Maven Wrapper files in exported project")
protected boolean mavenWrapper = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,12 @@ public Integer export() throws Exception {
});
// copy docker files
copyDockerFiles(BUILD_DIR);
String appJar = "target" + File.separator + "quarkus-app" + File.separator + "quarkus-run.jar";
String appJar;
if ("fast-jar".equals(quarkusPackageType)) {
appJar = "target" + File.separator + "quarkus-app" + File.separator + "quarkus-run.jar";
} else {
appJar = "target" + File.separator + ids[1] + "-" + ids[2] + ".jar";
}
copyReadme(BUILD_DIR, appJar);
// gather dependencies
Set<String> deps = resolveDependencies(settings, profile);
Expand Down Expand Up @@ -276,12 +281,27 @@ protected String applicationPropertyLine(String key, String value) {

@Override
protected void copyDockerFiles(String buildDir) throws Exception {
super.copyDockerFiles(buildDir);
if ("uber-jar".equals(quarkusPackageType)) {
// For uber-jar, the generic Dockerfile works as-is
super.copyDockerFiles(buildDir);
} else {
// For fast-jar, use a Quarkus-specific JVM Dockerfile
Path docker = Path.of(buildDir).resolve("src/main/docker");
Files.createDirectories(docker);
InputStream is
= ExportQuarkus.class.getClassLoader().getResourceAsStream("quarkus-docker/Dockerfile.jvm");
if (is != null) {
PathUtils.copyFromStream(is, docker.resolve("Dockerfile"), true);
}
}
// Quarkus-specific Dockerfiles for native builds
Path docker = Path.of(buildDir).resolve("src/main/docker");
Files.createDirectories(docker);
// copy files
InputStream is = ExportQuarkus.class.getClassLoader().getResourceAsStream("quarkus-docker/Dockerfile.native");
PathUtils.copyFromStream(is, docker.resolve("Dockerfile.native"), true);
for (String dockerfile : List.of("Dockerfile.native", "Dockerfile.native-micro")) {
InputStream is = ExportQuarkus.class.getClassLoader().getResourceAsStream("quarkus-docker/" + dockerfile);
if (is != null) {
PathUtils.copyFromStream(is, docker.resolve(dockerfile), true);
}
}
}

@Override
Expand Down Expand Up @@ -325,6 +345,7 @@ private void createMavenPom(Path settings, Path pom, Set<String> deps) throws Ex
context = context.replaceAll("\\{\\{ \\.QuarkusGroupId }}", quarkusGroupId);
context = context.replaceAll("\\{\\{ \\.QuarkusArtifactId }}", quarkusArtifactId);
context = context.replaceAll("\\{\\{ \\.QuarkusVersion }}", quarkusVersion);
context = context.replaceAll("\\{\\{ \\.QuarkusPackageType }}", quarkusPackageType);
context = context.replaceAll("\\{\\{ \\.QuarkusManagementPort }}", mp);
context = context.replaceAll("\\{\\{ \\.JavaVersion }}", javaVersion);
context = context.replaceAll("\\{\\{ \\.CamelVersion }}", camelVersion);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

####
# This Dockerfile is used in order to build a container that runs the Quarkus application in JVM mode
# using the fast-jar packaging.
#
# Before building the container image run:
#
# ./mvnw clean package
#
# Then, build the image with:
#
# docker build -f src/main/docker/Dockerfile -t quarkus/camel-app .
#
# Then run the container using:
#
# docker run -i --rm -p 8080:8080 quarkus/camel-app
#
###
FROM registry.access.redhat.com/ubi9/openjdk-21:1.23

ENV LANGUAGE='en_US:en'

# We make four distinct layers so if there are application changes the library layers can be re-used
COPY --chown=185 target/quarkus-app/lib/ /deployments/lib/
COPY --chown=185 target/quarkus-app/*.jar /deployments/
COPY --chown=185 target/quarkus-app/app/ /deployments/app/
COPY --chown=185 target/quarkus-app/quarkus/ /deployments/quarkus/

# Uncomment to expose any given port
# EXPOSE 8080
USER 185
ENV JAVA_OPTS_APPEND="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager"
ENV JAVA_APP_JAR="/deployments/quarkus-run.jar"

ENTRYPOINT [ "/opt/jboss/container/java/run/run-java.sh" ]
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
#
# docker run -i quarkus/code-with-quarkus
#
# The ` registry.access.redhat.com/ubi9/ubi-minimal:9.5` base image is based on UBI 9.
# The ` registry.access.redhat.com/ubi9/ubi-minimal:9.7` base image is based on UBI 9.
# To use UBI 8, switch to `quay.io/ubi8/ubi-minimal:8.10`.
###
FROM registry.access.redhat.com/ubi9/ubi-minimal:9.6
FROM registry.access.redhat.com/ubi9/ubi-minimal:9.7
WORKDIR /work/
RUN chown 1001 /work \
&& chmod "g+rwX" /work \
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

####
# This Dockerfile is used in order to build a container that runs the Quarkus application in native (no JVM) mode.
# It uses a micro base image, tuned for Quarkus native executables.
# It reduces the size of the resulting container image.
# Check https://quarkus.io/guides/quarkus-runtime-base-image for further information about this image.
#
# Before building the container image run:
#
# ./mvnw package -Dnative
#
# Then, build the image with:
#
# docker build -f src/main/docker/Dockerfile.native-micro -t quarkus/code-with-quarkus .
#
# Then run the container using:
#
# docker run -i --rm -p 8080:8080 quarkus/code-with-quarkus
#
# The `quay.io/quarkus/ubi9-quarkus-micro-image:2.0` base image is based on UBI 9.
# To use UBI 8, switch to `quay.io/quarkus/quarkus-micro-image:2.0`.
###
FROM quay.io/quarkus/ubi9-quarkus-micro-image:2.0
WORKDIR /work/
RUN chown 1001 /work \
&& chmod "g+rwX" /work \
&& chown 1001:root /work
COPY --chown=1001:root --chmod=0755 target/*-runner /work/application

# Uncomment to expose any given port
# EXPOSE 8080
USER 1001

# Use this if you're exposing some port
# ENTRYPOINT ["./application", "-Dquarkus.http.host=0.0.0.0"]
ENTRYPOINT ["./application"]
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<quarkus.platform.artifact-id>{{ .QuarkusArtifactId }}</quarkus.platform.artifact-id>
<quarkus.platform.version>{{ .QuarkusVersion }}</quarkus.platform.version>
{{ .BuildProperties }}
<quarkus.package.jar.type>{{ .QuarkusPackageType }}</quarkus.package.jar.type>
<skipITs>true</skipITs>
<surefire-plugin.version>3.5.5</surefire-plugin.version>
</properties>
Expand Down
Loading