Skip to content

Commit 226899a

Browse files
committed
CAMEL-23192: Adds missing dockerfiles
1 parent 4b0f16c commit 226899a

5 files changed

Lines changed: 298 additions & 4 deletions

File tree

dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportQuarkus.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,9 +279,19 @@ protected void copyDockerFiles(String buildDir) throws Exception {
279279
super.copyDockerFiles(buildDir);
280280
Path docker = Path.of(buildDir).resolve("src/main/docker");
281281
Files.createDirectories(docker);
282-
// copy files
283-
InputStream is = ExportQuarkus.class.getClassLoader().getResourceAsStream("quarkus-docker/Dockerfile.native");
284-
PathUtils.copyFromStream(is, docker.resolve("Dockerfile.native"), true);
282+
// copy all Dockerfile variants
283+
List<String> dockerfiles = List.of(
284+
"Dockerfile.jvm",
285+
"Dockerfile.legacy-jar",
286+
"Dockerfile.native",
287+
"Dockerfile.native-micro"
288+
);
289+
for (String dockerfile : dockerfiles) {
290+
InputStream is = ExportQuarkus.class.getClassLoader().getResourceAsStream("quarkus-docker/" + dockerfile);
291+
if (is != null) {
292+
PathUtils.copyFromStream(is, docker.resolve(dockerfile), true);
293+
}
294+
}
285295
}
286296

287297
@Override
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one or more
3+
# contributor license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright ownership.
5+
# The ASF licenses this file to You under the Apache License, Version 2.0
6+
# (the "License"); you may not use this file except in compliance with
7+
# the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
####
19+
# This Dockerfile is used in order to build a container that runs the Quarkus application in JVM mode
20+
#
21+
# Before building the container image run:
22+
#
23+
# ./mvnw package
24+
#
25+
# Then, build the image with:
26+
#
27+
# docker build -f src/main/docker/Dockerfile.jvm -t quarkus/code-with-quarkus-jvm .
28+
#
29+
# Then run the container using:
30+
#
31+
# docker run -i --rm -p 8080:8080 quarkus/code-with-quarkus-jvm
32+
#
33+
# If you want to include the debug port into your docker image
34+
# you will have to expose the debug port (default 5005 being the default) like this : EXPOSE 8080 5005.
35+
# Additionally you will have to set -e JAVA_DEBUG=true and -e JAVA_DEBUG_PORT=*:5005
36+
# when running the container
37+
#
38+
# Then run the container using :
39+
#
40+
# docker run -i --rm -p 8080:8080 quarkus/code-with-quarkus-jvm
41+
#
42+
# This image uses the `run-java.sh` script to run the application.
43+
# This scripts computes the command line to execute your Java application, and
44+
# includes memory/GC tuning.
45+
# You can configure the behavior using the following environment properties:
46+
# - JAVA_OPTS: JVM options passed to the `java` command (example: "-verbose:class") - Be aware that this will override
47+
# the default JVM options, use `JAVA_OPTS_APPEND` to append options
48+
# - JAVA_OPTS_APPEND: User specified Java options to be appended to generated options
49+
# in JAVA_OPTS (example: "-Dsome.property=foo")
50+
# - JAVA_MAX_MEM_RATIO: Is used when no `-Xmx` option is given in JAVA_OPTS. This is
51+
# used to calculate a default maximal heap memory based on a containers restriction.
52+
# If used in a container without any memory constraints for the container then this
53+
# option has no effect. If there is a memory constraint then `-Xmx` is set to a ratio
54+
# of the container available memory as set here. The default is `50` which means 50%
55+
# of the available memory is used as an upper boundary. You can skip this mechanism by
56+
# setting this value to `0` in which case no `-Xmx` option is added.
57+
# - JAVA_INITIAL_MEM_RATIO: Is used when no `-Xms` option is given in JAVA_OPTS. This
58+
# is used to calculate a default initial heap memory based on the maximum heap memory.
59+
# If used in a container without any memory constraints for the container then this
60+
# option has no effect. If there is a memory constraint then `-Xms` is set to a ratio
61+
# of the `-Xmx` memory as set here. The default is `25` which means 25% of the `-Xmx`
62+
# is used as the initial heap size. You can skip this mechanism by setting this value
63+
# to `0` in which case no `-Xms` option is added (example: "25")
64+
# - JAVA_MAX_INITIAL_MEM: Is used when no `-Xms` option is given in JAVA_OPTS.
65+
# This is used to calculate the maximum value of the initial heap memory. If used in
66+
# a container without any memory constraints for the container then this option has
67+
# no effect. If there is a memory constraint then `-Xms` is limited to the value set
68+
# here. The default is 4096MB which means the calculated value of `-Xms` never will
69+
# be greater than 4096MB. The value of this variable is expressed in MB (example: "4096")
70+
# - JAVA_DIAGNOSTICS: Set this to get some diagnostics information to standard output
71+
# when things are happening. This option, if set to true, will set
72+
# `-XX:+UnlockDiagnosticVMOptions`. Disabled by default (example: "true").
73+
# - JAVA_DEBUG: If set remote debugging will be switched on. Disabled by default (example:
74+
# true").
75+
# - JAVA_DEBUG_PORT: Port used for remote debugging. Defaults to 5005 (example: "8787").
76+
# - CONTAINER_CORE_LIMIT: A calculated core limit as described in
77+
# https://www.kernel.org/doc/Documentation/scheduler/sched-bwc.txt. (example: "2")
78+
# - CONTAINER_MAX_MEMORY: Memory limit given to the container (example: "1024").
79+
# - GC_MIN_HEAP_FREE_RATIO: Minimum percentage of heap free after GC to avoid expansion.
80+
# (example: "20")
81+
# - GC_MAX_HEAP_FREE_RATIO: Maximum percentage of heap free after GC to avoid shrinking.
82+
# (example: "40")
83+
# - GC_TIME_RATIO: Specifies the ratio of the time spent outside the garbage collection.
84+
# (example: "4")
85+
# - GC_ADAPTIVE_SIZE_POLICY_WEIGHT: The weighting given to the current GC time versus
86+
# previous GC times. (example: "90")
87+
# - GC_METASPACE_SIZE: The initial metaspace size. (example: "20")
88+
# - GC_MAX_METASPACE_SIZE: The maximum metaspace size. (example: "100")
89+
# - GC_CONTAINER_OPTIONS: Specify Java GC to use. The value of this variable should
90+
# contain the necessary JRE command-line options to specify the required GC, which
91+
# will override the default of `-XX:+UseParallelGC` (example: -XX:+UseG1GC).
92+
# - HTTPS_PROXY: The location of the https proxy. (example: "myuser@127.0.0.1:8080")
93+
# - HTTP_PROXY: The location of the http proxy. (example: "myuser@127.0.0.1:8080")
94+
# - NO_PROXY: A comma separated lists of hosts, IP addresses or domains that can be
95+
# accessed directly. (example: "foo.example.com,bar.example.com")
96+
#
97+
###
98+
FROM registry.access.redhat.com/ubi9/openjdk-21:1.23
99+
100+
ENV LANGUAGE='en_US:en'
101+
102+
103+
# We make four distinct layers so if there are application changes the library layers can be re-used
104+
COPY --chown=185 target/quarkus-app/lib/ /deployments/lib/
105+
COPY --chown=185 target/quarkus-app/*.jar /deployments/
106+
COPY --chown=185 target/quarkus-app/app/ /deployments/app/
107+
COPY --chown=185 target/quarkus-app/quarkus/ /deployments/quarkus/
108+
109+
# Uncomment to expose any given port
110+
# EXPOSE 8080
111+
USER 185
112+
# Use this if you're exposing some port
113+
#ENV JAVA_OPTS_APPEND="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager"
114+
ENV JAVA_OPTS_APPEND="-Djava.util.logging.manager=org.jboss.logmanager.LogManager"
115+
ENV JAVA_APP_JAR="/deployments/quarkus-run.jar"
116+
117+
ENTRYPOINT [ "/opt/jboss/container/java/run/run-java.sh" ]
118+
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one or more
3+
# contributor license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright ownership.
5+
# The ASF licenses this file to You under the Apache License, Version 2.0
6+
# (the "License"); you may not use this file except in compliance with
7+
# the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
####
19+
# This Dockerfile is used in order to build a container that runs the Quarkus application in JVM mode
20+
#
21+
# Before building the container image run:
22+
#
23+
# ./mvnw package -Dquarkus.package.jar.type=legacy-jar
24+
#
25+
# Then, build the image with:
26+
#
27+
# docker build -f src/main/docker/Dockerfile.legacy-jar -t quarkus/code-with-quarkus-legacy-jar .
28+
#
29+
# Then run the container using:
30+
#
31+
# docker run -i --rm -p 8080:8080 quarkus/code-with-quarkus-legacy-jar
32+
#
33+
# If you want to include the debug port into your docker image
34+
# you will have to expose the debug port (default 5005 being the default) like this : EXPOSE 8080 5005.
35+
# Additionally you will have to set -e JAVA_DEBUG=true and -e JAVA_DEBUG_PORT=*:5005
36+
# when running the container
37+
#
38+
# Then run the container using :
39+
#
40+
# docker run -i --rm -p 8080:8080 quarkus/code-with-quarkus-legacy-jar
41+
#
42+
# This image uses the `run-java.sh` script to run the application.
43+
# This scripts computes the command line to execute your Java application, and
44+
# includes memory/GC tuning.
45+
# You can configure the behavior using the following environment properties:
46+
# - JAVA_OPTS: JVM options passed to the `java` command (example: "-verbose:class") - Be aware that this will override
47+
# the default JVM options, use `JAVA_OPTS_APPEND` to append options
48+
# - JAVA_OPTS_APPEND: User specified Java options to be appended to generated options
49+
# in JAVA_OPTS (example: "-Dsome.property=foo")
50+
# - JAVA_MAX_MEM_RATIO: Is used when no `-Xmx` option is given in JAVA_OPTS. This is
51+
# used to calculate a default maximal heap memory based on a containers restriction.
52+
# If used in a container without any memory constraints for the container then this
53+
# option has no effect. If there is a memory constraint then `-Xmx` is set to a ratio
54+
# of the container available memory as set here. The default is `50` which means 50%
55+
# of the available memory is used as an upper boundary. You can skip this mechanism by
56+
# setting this value to `0` in which case no `-Xmx` option is added.
57+
# - JAVA_INITIAL_MEM_RATIO: Is used when no `-Xms` option is given in JAVA_OPTS. This
58+
# is used to calculate a default initial heap memory based on the maximum heap memory.
59+
# If used in a container without any memory constraints for the container then this
60+
# option has no effect. If there is a memory constraint then `-Xms` is set to a ratio
61+
# of the `-Xmx` memory as set here. The default is `25` which means 25% of the `-Xmx`
62+
# is used as the initial heap size. You can skip this mechanism by setting this value
63+
# to `0` in which case no `-Xms` option is added (example: "25")
64+
# - JAVA_MAX_INITIAL_MEM: Is used when no `-Xms` option is given in JAVA_OPTS.
65+
# This is used to calculate the maximum value of the initial heap memory. If used in
66+
# a container without any memory constraints for the container then this option has
67+
# no effect. If there is a memory constraint then `-Xms` is limited to the value set
68+
# here. The default is 4096MB which means the calculated value of `-Xms` never will
69+
# be greater than 4096MB. The value of this variable is expressed in MB (example: "4096")
70+
# - JAVA_DIAGNOSTICS: Set this to get some diagnostics information to standard output
71+
# when things are happening. This option, if set to true, will set
72+
# `-XX:+UnlockDiagnosticVMOptions`. Disabled by default (example: "true").
73+
# - JAVA_DEBUG: If set remote debugging will be switched on. Disabled by default (example:
74+
# true").
75+
# - JAVA_DEBUG_PORT: Port used for remote debugging. Defaults to 5005 (example: "8787").
76+
# - CONTAINER_CORE_LIMIT: A calculated core limit as described in
77+
# https://www.kernel.org/doc/Documentation/scheduler/sched-bwc.txt. (example: "2")
78+
# - CONTAINER_MAX_MEMORY: Memory limit given to the container (example: "1024").
79+
# - GC_MIN_HEAP_FREE_RATIO: Minimum percentage of heap free after GC to avoid expansion.
80+
# (example: "20")
81+
# - GC_MAX_HEAP_FREE_RATIO: Maximum percentage of heap free after GC to avoid shrinking.
82+
# (example: "40")
83+
# - GC_TIME_RATIO: Specifies the ratio of the time spent outside the garbage collection.
84+
# (example: "4")
85+
# - GC_ADAPTIVE_SIZE_POLICY_WEIGHT: The weighting given to the current GC time versus
86+
# previous GC times. (example: "90")
87+
# - GC_METASPACE_SIZE: The initial metaspace size. (example: "20")
88+
# - GC_MAX_METASPACE_SIZE: The maximum metaspace size. (example: "100")
89+
# - GC_CONTAINER_OPTIONS: Specify Java GC to use. The value of this variable should
90+
# contain the necessary JRE command-line options to specify the required GC, which
91+
# will override the default of `-XX:+UseParallelGC` (example: -XX:+UseG1GC).
92+
# - HTTPS_PROXY: The location of the https proxy. (example: "myuser@127.0.0.1:8080")
93+
# - HTTP_PROXY: The location of the http proxy. (example: "myuser@127.0.0.1:8080")
94+
# - NO_PROXY: A comma separated lists of hosts, IP addresses or domains that can be
95+
# accessed directly. (example: "foo.example.com,bar.example.com")
96+
#
97+
###
98+
FROM registry.access.redhat.com/ubi9/openjdk-21:1.23
99+
100+
ENV LANGUAGE='en_US:en'
101+
102+
103+
COPY target/lib/* /deployments/lib/
104+
COPY target/*-runner.jar /deployments/quarkus-run.jar
105+
106+
# Uncomment to expose any given port
107+
# EXPOSE 8080
108+
USER 185
109+
# Use this if you're exposing some port
110+
#ENV JAVA_OPTS_APPEND="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager"
111+
ENV JAVA_OPTS_APPEND="-Djava.util.logging.manager=org.jboss.logmanager.LogManager"
112+
ENV JAVA_APP_JAR="/deployments/quarkus-run.jar"
113+
114+
ENTRYPOINT [ "/opt/jboss/container/java/run/run-java.sh" ]

dsl/camel-jbang/camel-jbang-core/src/main/resources/quarkus-docker/Dockerfile.native

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
#
3131
# docker run -i quarkus/code-with-quarkus
3232
#
33-
# The ` registry.access.redhat.com/ubi9/ubi-minimal:9.5` base image is based on UBI 9.
33+
# The ` registry.access.redhat.com/ubi9/ubi-minimal:9.6` base image is based on UBI 9.
3434
# To use UBI 8, switch to `quay.io/ubi8/ubi-minimal:8.10`.
3535
###
3636
FROM registry.access.redhat.com/ubi9/ubi-minimal:9.6
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one or more
3+
# contributor license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright ownership.
5+
# The ASF licenses this file to You under the Apache License, Version 2.0
6+
# (the "License"); you may not use this file except in compliance with
7+
# the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
####
19+
# This Dockerfile is used in order to build a container that runs the Quarkus application in native (no JVM) mode.
20+
# It uses a micro base image, tuned for Quarkus native executables.
21+
# It reduces the size of the resulting container image.
22+
# Check https://quarkus.io/guides/quarkus-runtime-base-image for further information about this image.
23+
#
24+
# Before building the container image run:
25+
#
26+
# ./mvnw package -Dnative
27+
#
28+
# Then, build the image with:
29+
#
30+
# docker build -f src/main/docker/Dockerfile.native-micro -t quarkus/code-with-quarkus .
31+
#
32+
# Then run the container using:
33+
#
34+
# docker run -i --rm -p 8080:8080 quarkus/code-with-quarkus
35+
#
36+
# The `quay.io/quarkus/ubi9-quarkus-micro-image:2.0` base image is based on UBI 9.
37+
# To use UBI 8, switch to `quay.io/quarkus/quarkus-micro-image:2.0`.
38+
###
39+
FROM quay.io/quarkus/ubi9-quarkus-micro-image:2.0
40+
WORKDIR /work/
41+
RUN chown 1001 /work \
42+
&& chmod "g+rwX" /work \
43+
&& chown 1001:root /work
44+
COPY --chown=1001:root --chmod=0755 target/*-runner /work/application
45+
46+
# Uncomment to expose any given port
47+
# EXPOSE 8080
48+
USER 1001
49+
50+
# Use this if you're exposing some port
51+
# ENTRYPOINT ["./application", "-Dquarkus.http.host=0.0.0.0"]
52+
ENTRYPOINT ["./application"]

0 commit comments

Comments
 (0)