Skip to content

Commit 6007093

Browse files
authored
Add dockerfiles to Observability example project
1 parent 8bca21f commit 6007093

5 files changed

Lines changed: 329 additions & 0 deletions

File tree

observability/pom.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,10 @@
254254
</excludes>
255255
<mapping>
256256
<java>SLASHSTAR_STYLE</java>
257+
<jvm>CAMEL_PROPERTIES_STYLE</jvm>
258+
<legacy-jar>CAMEL_PROPERTIES_STYLE</legacy-jar>
259+
<native>CAMEL_PROPERTIES_STYLE</native>
260+
<native-micro>CAMEL_PROPERTIES_STYLE</native-micro>
257261
<properties>CAMEL_PROPERTIES_STYLE</properties>
258262
<kt>SLASHSTAR_STYLE</kt>
259263
</mapping>
@@ -407,6 +411,10 @@
407411
</excludes>
408412
<mapping>
409413
<java>SLASHSTAR_STYLE</java>
414+
<jvm>CAMEL_PROPERTIES_STYLE</jvm>
415+
<legacy-jar>CAMEL_PROPERTIES_STYLE</legacy-jar>
416+
<native>CAMEL_PROPERTIES_STYLE</native>
417+
<native-micro>CAMEL_PROPERTIES_STYLE</native-micro>
410418
<properties>CAMEL_PROPERTIES_STYLE</properties>
411419
<kt>SLASHSTAR_STYLE</kt>
412420
</mapping>
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
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+
# This Dockerfile is used in order to build a container that runs the Quarkus application in JVM mode
19+
#
20+
# Before building the container image run:
21+
#
22+
# ./mvnw package
23+
#
24+
# Then, build the image with:
25+
#
26+
# docker build -f src/main/docker/Dockerfile.jvm -t quarkus/observability-jvm .
27+
#
28+
# Then run the container using:
29+
#
30+
# docker run -i --rm -p 8080:8080 quarkus/observability-jvm
31+
#
32+
# If you want to include the debug port into your docker image
33+
# you will have to expose the debug port (default 5005 being the default) like this : EXPOSE 8080 5005.
34+
# Additionally you will have to set -e JAVA_DEBUG=true and -e JAVA_DEBUG_PORT=*:5005
35+
# when running the container
36+
#
37+
# Then run the container using :
38+
#
39+
# docker run -i --rm -p 8080:8080 quarkus/observability-jvm
40+
#
41+
# This image uses the `run-java.sh` script to run the application.
42+
# This scripts computes the command line to execute your Java application, and
43+
# includes memory/GC tuning.
44+
# You can configure the behavior using the following environment properties:
45+
# - JAVA_OPTS: JVM options passed to the `java` command (example: "-verbose:class") - Be aware that this will override
46+
# the default JVM options, use `JAVA_OPTS_APPEND` to append options
47+
# - JAVA_OPTS_APPEND: User specified Java options to be appended to generated options
48+
# in JAVA_OPTS (example: "-Dsome.property=foo")
49+
# - JAVA_MAX_MEM_RATIO: Is used when no `-Xmx` option is given in JAVA_OPTS. This is
50+
# used to calculate a default maximal heap memory based on a containers restriction.
51+
# If used in a container without any memory constraints for the container then this
52+
# option has no effect. If there is a memory constraint then `-Xmx` is set to a ratio
53+
# of the container available memory as set here. The default is `50` which means 50%
54+
# of the available memory is used as an upper boundary. You can skip this mechanism by
55+
# setting this value to `0` in which case no `-Xmx` option is added.
56+
# - JAVA_INITIAL_MEM_RATIO: Is used when no `-Xms` option is given in JAVA_OPTS. This
57+
# is used to calculate a default initial heap memory based on the maximum heap memory.
58+
# If used in a container without any memory constraints for the container then this
59+
# option has no effect. If there is a memory constraint then `-Xms` is set to a ratio
60+
# of the `-Xmx` memory as set here. The default is `25` which means 25% of the `-Xmx`
61+
# is used as the initial heap size. You can skip this mechanism by setting this value
62+
# to `0` in which case no `-Xms` option is added (example: "25")
63+
# - JAVA_MAX_INITIAL_MEM: Is used when no `-Xms` option is given in JAVA_OPTS.
64+
# This is used to calculate the maximum value of the initial heap memory. If used in
65+
# a container without any memory constraints for the container then this option has
66+
# no effect. If there is a memory constraint then `-Xms` is limited to the value set
67+
# here. The default is 4096MB which means the calculated value of `-Xms` never will
68+
# be greater than 4096MB. The value of this variable is expressed in MB (example: "4096")
69+
# - JAVA_DIAGNOSTICS: Set this to get some diagnostics information to standard output
70+
# when things are happening. This option, if set to true, will set
71+
# `-XX:+UnlockDiagnosticVMOptions`. Disabled by default (example: "true").
72+
# - JAVA_DEBUG: If set remote debugging will be switched on. Disabled by default (example:
73+
# true").
74+
# - JAVA_DEBUG_PORT: Port used for remote debugging. Defaults to 5005 (example: "8787").
75+
# - CONTAINER_CORE_LIMIT: A calculated core limit as described in
76+
# https://www.kernel.org/doc/Documentation/scheduler/sched-bwc.txt. (example: "2")
77+
# - CONTAINER_MAX_MEMORY: Memory limit given to the container (example: "1024").
78+
# - GC_MIN_HEAP_FREE_RATIO: Minimum percentage of heap free after GC to avoid expansion.
79+
# (example: "20")
80+
# - GC_MAX_HEAP_FREE_RATIO: Maximum percentage of heap free after GC to avoid shrinking.
81+
# (example: "40")
82+
# - GC_TIME_RATIO: Specifies the ratio of the time spent outside the garbage collection.
83+
# (example: "4")
84+
# - GC_ADAPTIVE_SIZE_POLICY_WEIGHT: The weighting given to the current GC time versus
85+
# previous GC times. (example: "90")
86+
# - GC_METASPACE_SIZE: The initial metaspace size. (example: "20")
87+
# - GC_MAX_METASPACE_SIZE: The maximum metaspace size. (example: "100")
88+
# - GC_CONTAINER_OPTIONS: Specify Java GC to use. The value of this variable should
89+
# contain the necessary JRE command-line options to specify the required GC, which
90+
# will override the default of `-XX:+UseParallelGC` (example: -XX:+UseG1GC).
91+
# - HTTPS_PROXY: The location of the https proxy. (example: "myuser@127.0.0.1:8080")
92+
# - HTTP_PROXY: The location of the http proxy. (example: "myuser@127.0.0.1:8080")
93+
# - NO_PROXY: A comma separated lists of hosts, IP addresses or domains that can be
94+
# accessed directly. (example: "foo.example.com,bar.example.com")
95+
#
96+
# You can find more information about the UBI base runtime images and their configuration here:
97+
# https://rh-openjdk.github.io/redhat-openjdk-containers/
98+
###
99+
FROM registry.access.redhat.com/ubi9/openjdk-21-runtime:1.24
100+
101+
ENV LANGUAGE='en_US:en'
102+
103+
104+
# We make four distinct layers so if there are application changes the library layers can be re-used
105+
COPY --chown=185 target/quarkus-app/lib/ /deployments/lib/
106+
COPY --chown=185 target/quarkus-app/*.jar /deployments/
107+
COPY --chown=185 target/quarkus-app/app/ /deployments/app/
108+
COPY --chown=185 target/quarkus-app/quarkus/ /deployments/quarkus/
109+
110+
EXPOSE 8080
111+
USER 185
112+
ENV JAVA_OPTS_APPEND="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager"
113+
ENV JAVA_APP_JAR="/deployments/quarkus-run.jar"
114+
115+
ENTRYPOINT [ "/opt/jboss/container/java/run/run-java.sh" ]
116+
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
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+
# This Dockerfile is used in order to build a container that runs the Quarkus application in JVM mode
19+
#
20+
# Before building the container image run:
21+
#
22+
# ./mvnw package -Dquarkus.package.jar.type=legacy-jar
23+
#
24+
# Then, build the image with:
25+
#
26+
# docker build -f src/main/docker/Dockerfile.legacy-jar -t quarkus/observability-legacy-jar .
27+
#
28+
# Then run the container using:
29+
#
30+
# docker run -i --rm -p 8080:8080 quarkus/observability-legacy-jar
31+
#
32+
# If you want to include the debug port into your docker image
33+
# you will have to expose the debug port (default 5005 being the default) like this : EXPOSE 8080 5005.
34+
# Additionally you will have to set -e JAVA_DEBUG=true and -e JAVA_DEBUG_PORT=*:5005
35+
# when running the container
36+
#
37+
# Then run the container using :
38+
#
39+
# docker run -i --rm -p 8080:8080 quarkus/observability-legacy-jar
40+
#
41+
# This image uses the `run-java.sh` script to run the application.
42+
# This scripts computes the command line to execute your Java application, and
43+
# includes memory/GC tuning.
44+
# You can configure the behavior using the following environment properties:
45+
# - JAVA_OPTS: JVM options passed to the `java` command (example: "-verbose:class") - Be aware that this will override
46+
# the default JVM options, use `JAVA_OPTS_APPEND` to append options
47+
# - JAVA_OPTS_APPEND: User specified Java options to be appended to generated options
48+
# in JAVA_OPTS (example: "-Dsome.property=foo")
49+
# - JAVA_MAX_MEM_RATIO: Is used when no `-Xmx` option is given in JAVA_OPTS. This is
50+
# used to calculate a default maximal heap memory based on a containers restriction.
51+
# If used in a container without any memory constraints for the container then this
52+
# option has no effect. If there is a memory constraint then `-Xmx` is set to a ratio
53+
# of the container available memory as set here. The default is `50` which means 50%
54+
# of the available memory is used as an upper boundary. You can skip this mechanism by
55+
# setting this value to `0` in which case no `-Xmx` option is added.
56+
# - JAVA_INITIAL_MEM_RATIO: Is used when no `-Xms` option is given in JAVA_OPTS. This
57+
# is used to calculate a default initial heap memory based on the maximum heap memory.
58+
# If used in a container without any memory constraints for the container then this
59+
# option has no effect. If there is a memory constraint then `-Xms` is set to a ratio
60+
# of the `-Xmx` memory as set here. The default is `25` which means 25% of the `-Xmx`
61+
# is used as the initial heap size. You can skip this mechanism by setting this value
62+
# to `0` in which case no `-Xms` option is added (example: "25")
63+
# - JAVA_MAX_INITIAL_MEM: Is used when no `-Xms` option is given in JAVA_OPTS.
64+
# This is used to calculate the maximum value of the initial heap memory. If used in
65+
# a container without any memory constraints for the container then this option has
66+
# no effect. If there is a memory constraint then `-Xms` is limited to the value set
67+
# here. The default is 4096MB which means the calculated value of `-Xms` never will
68+
# be greater than 4096MB. The value of this variable is expressed in MB (example: "4096")
69+
# - JAVA_DIAGNOSTICS: Set this to get some diagnostics information to standard output
70+
# when things are happening. This option, if set to true, will set
71+
# `-XX:+UnlockDiagnosticVMOptions`. Disabled by default (example: "true").
72+
# - JAVA_DEBUG: If set remote debugging will be switched on. Disabled by default (example:
73+
# true").
74+
# - JAVA_DEBUG_PORT: Port used for remote debugging. Defaults to 5005 (example: "8787").
75+
# - CONTAINER_CORE_LIMIT: A calculated core limit as described in
76+
# https://www.kernel.org/doc/Documentation/scheduler/sched-bwc.txt. (example: "2")
77+
# - CONTAINER_MAX_MEMORY: Memory limit given to the container (example: "1024").
78+
# - GC_MIN_HEAP_FREE_RATIO: Minimum percentage of heap free after GC to avoid expansion.
79+
# (example: "20")
80+
# - GC_MAX_HEAP_FREE_RATIO: Maximum percentage of heap free after GC to avoid shrinking.
81+
# (example: "40")
82+
# - GC_TIME_RATIO: Specifies the ratio of the time spent outside the garbage collection.
83+
# (example: "4")
84+
# - GC_ADAPTIVE_SIZE_POLICY_WEIGHT: The weighting given to the current GC time versus
85+
# previous GC times. (example: "90")
86+
# - GC_METASPACE_SIZE: The initial metaspace size. (example: "20")
87+
# - GC_MAX_METASPACE_SIZE: The maximum metaspace size. (example: "100")
88+
# - GC_CONTAINER_OPTIONS: Specify Java GC to use. The value of this variable should
89+
# contain the necessary JRE command-line options to specify the required GC, which
90+
# will override the default of `-XX:+UseParallelGC` (example: -XX:+UseG1GC).
91+
# - HTTPS_PROXY: The location of the https proxy. (example: "myuser@127.0.0.1:8080")
92+
# - HTTP_PROXY: The location of the http proxy. (example: "myuser@127.0.0.1:8080")
93+
# - NO_PROXY: A comma separated lists of hosts, IP addresses or domains that can be
94+
# accessed directly. (example: "foo.example.com,bar.example.com")
95+
#
96+
# You can find more information about the UBI base runtime images and their configuration here:
97+
# https://rh-openjdk.github.io/redhat-openjdk-containers/
98+
###
99+
FROM registry.access.redhat.com/ubi9/openjdk-21-runtime:1.24
100+
101+
ENV LANGUAGE='en_US:en'
102+
103+
104+
COPY target/lib/* /deployments/lib/
105+
COPY target/*-runner.jar /deployments/quarkus-run.jar
106+
107+
EXPOSE 8080
108+
USER 185
109+
ENV JAVA_OPTS_APPEND="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager"
110+
ENV JAVA_APP_JAR="/deployments/quarkus-run.jar"
111+
112+
ENTRYPOINT [ "/opt/jboss/container/java/run/run-java.sh" ]
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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+
# This Dockerfile is used in order to build a container that runs the Quarkus application in native (no JVM) mode.
19+
#
20+
# Before building the container image run:
21+
#
22+
# ./mvnw package -Dnative
23+
#
24+
# Then, build the image with:
25+
#
26+
# docker build -f src/main/docker/Dockerfile.native -t quarkus/observability .
27+
#
28+
# Then run the container using:
29+
#
30+
# docker run -i --rm -p 8080:8080 quarkus/observability
31+
#
32+
# The ` registry.access.redhat.com/ubi9/ubi-minimal:9.7` base image is based on UBI 9.
33+
# To use UBI 8, switch to `quay.io/ubi8/ubi-minimal:8.10`.
34+
###
35+
FROM registry.access.redhat.com/ubi9/ubi-minimal:9.7
36+
WORKDIR /work/
37+
RUN chown 1001 /work \
38+
&& chmod "g+rwX" /work \
39+
&& chown 1001:root /work
40+
COPY --chown=1001:root --chmod=0755 target/*-runner /work/application
41+
42+
EXPOSE 8080
43+
USER 1001
44+
45+
ENTRYPOINT ["./application", "-Dquarkus.http.host=0.0.0.0"]
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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+
# This Dockerfile is used in order to build a container that runs the Quarkus application in native (no JVM) mode.
19+
# It uses a micro base image, tuned for Quarkus native executables.
20+
# It reduces the size of the resulting container image.
21+
# Check https://quarkus.io/guides/quarkus-runtime-base-image for further information about this image.
22+
#
23+
# Before building the container image run:
24+
#
25+
# ./mvnw package -Dnative
26+
#
27+
# Then, build the image with:
28+
#
29+
# docker build -f src/main/docker/Dockerfile.native-micro -t quarkus/observability .
30+
#
31+
# Then run the container using:
32+
#
33+
# docker run -i --rm -p 8080:8080 quarkus/observability
34+
#
35+
# The `quay.io/quarkus/ubi9-quarkus-micro-image:2.0` base image is based on UBI 9.
36+
# To use UBI 8, switch to `quay.io/quarkus/quarkus-micro-image:2.0`.
37+
###
38+
FROM quay.io/quarkus/ubi9-quarkus-micro-image:2.0
39+
WORKDIR /work/
40+
RUN chown 1001 /work \
41+
&& chmod "g+rwX" /work \
42+
&& chown 1001:root /work
43+
COPY --chown=1001:root --chmod=0755 target/*-runner /work/application
44+
45+
EXPOSE 8080
46+
USER 1001
47+
48+
ENTRYPOINT ["./application", "-Dquarkus.http.host=0.0.0.0"]

0 commit comments

Comments
 (0)