Skip to content

Commit d431deb

Browse files
committed
QDOCS-1060: create docker build procedures
Signed-off-by: shjones <[email protected]>
1 parent eba4923 commit d431deb

File tree

1 file changed

+160
-0
lines changed

1 file changed

+160
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
////
2+
This guide is maintained in the main Quarkus repository
3+
and pull requests should be submitted there:
4+
https://github.com/quarkusio/quarkus/tree/main/docs/src/main/asciidoc
5+
////
6+
[id="deploying-to-openshift-docker-howto"]
7+
= Deploy {project-name} Java applications to OpenShift by using Docker build
8+
include::_attributes.adoc[]
9+
:diataxis-type: howto
10+
:categories: cloud, native
11+
:summary: This guide covers how to build and deploy a Quarkus application on OpenShift by using Docker builds.
12+
:topics: devops,kubernetes,openshift,cloud,deployment
13+
:extensions: io.quarkus:quarkus-openshift
14+
15+
This guide describes how to deploy {project-name} applications to OpenShift by using Docker build.
16+
17+
As an application developer, you can deploy your Quarkus applications to OpenShift by using the Docker build strategy as a deployment option.
18+
This functionality is provided by the `quarkus-openshift` extension, which supports multiple deployment options, including the Docker build strategy and the Source-to-Image (S2I) strategy.
19+
20+
== Prerequisites
21+
22+
* You have OpenJDK 17 or later installed.
23+
* You have set the `JAVA_HOME` environment variable to the location of the Java SDK.
24+
* You have Apache Maven {maven-version} installed.
25+
* You have a Quarkus project that includes the `quarkus-openshift` extension.
26+
//** To add the Quarkus OpenShift extension, see xref:proc_adding-the-quarkus-openshift-extension_quarkus-openshift[Adding the {ProductName} OpenShift extension].
27+
* You have access to an OpenShift cluster and the latest compatible version of the `oc` tool installed.
28+
29+
== Procedure
30+
31+
. Set the Docker build strategy in your `application.properties` configuration file:
32+
+
33+
[source, properties]
34+
----
35+
quarkus.openshift.build-strategy=docker
36+
----
37+
. Optional: Set the following properties in the `application.properties` file, as required by your environment:
38+
.. If you are using an untrusted certificate, configure the `KubernetesClient`:
39+
+
40+
[source,properties]
41+
----
42+
quarkus.kubernetes-client.trust-certs=true
43+
----
44+
.. Expose the service to create an {RHOSSHORT} route:
45+
+
46+
[source,properties]
47+
----
48+
quarkus.openshift.route.expose=true
49+
----
50+
.. Set the path to your custom Dockerfile:
51+
+
52+
[source,properties,subs="attributes+,+quotes"]
53+
----
54+
quarkus.openshift.jvm-dockerfile=<path_to_your_dockerfile>
55+
----
56+
The following example shows the path to the `Dockerfile.custom-jvm`:
57+
+
58+
[source,properties]
59+
----
60+
quarkus.openshift.jvm-dockerfile=src/main/resources/Dockerfile.custom-jvm
61+
----
62+
63+
64+
. Package and deploy your Quarkus application to the current OpenShift project:
65+
+
66+
[source,shell,subs="attributes+,+quotes"]
67+
----
68+
./mvnw clean package -Dquarkus.openshift.deploy=true
69+
----
70+
71+
72+
== Verification
73+
74+
75+
The verification steps and related terminal outputs are demonstrated on the `openshift-helloworld` example application.
76+
77+
78+
. Display the list of pods associated with your current OpenShift project:
79+
+
80+
[source,shell,subs="+quotes",options="nowrap"]
81+
----
82+
oc get pods
83+
----
84+
+
85+
[source,shell,subs="+quotes",options="nowrap"]
86+
----
87+
NAME READY STATUS RESTARTS AGE
88+
openshift-helloworld-1-build 0/1 Completed 0 11m
89+
openshift-helloworld-1-deploy 0/1 Completed 0 10m
90+
openshift-helloworld-1-gzzrx 1/1 Running 0 10m
91+
----
92+
93+
94+
95+
96+
. To retrieve the log output for your application's pod, use the `oc logs -f` command with the `<pod_name>` value of the pod you are interested in.
97+
In this example, we use the `openshift-helloworld-1-gzzrx` pod name that corresponds with the latest pod prefixed with the name of your application:
98+
+
99+
[source,shell,subs="+quotes",options="nowrap"]
100+
----
101+
oc logs -f _openshift-helloworld-1-gzzrx_
102+
----
103+
+
104+
[source,shell,subs=attributes+]
105+
----
106+
Starting the Java application using /opt/jboss/container/java/run/run-java.sh ...
107+
INFO exec -a "java" java -Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager -XX:MaxRAMPercentage=50.0 -XX:+UseParallelGC -XX:MinHeapFreeRatio=10 -XX:MaxHeapFreeRatio=20 -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -XX:+ExitOnOutOfMemoryError -cp "." -jar /deployments/quarkus-run.jar
108+
__ ____ __ _____ ___ __ ____ ______
109+
--/ __ \/ / / / _ | / _ \/ //_/ / / / __/
110+
-/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \
111+
--\___\_\____/_/ |_/_/|_/_/|_|\____/___/
112+
2024-09-17 10:23:25,254 INFO [io.quarkus] (main) getting-started 1.0.0-SNAPSHOT on JVM (powered by Quarkus {QuarkusCore}) started in 0.653s. Listening on: http://0.0.0.0:8080
113+
2024-09-17 10:23:25,281 INFO [io.quarkus] (main) Profile prod activated.
114+
2024-09-17 10:23:25,281 INFO [io.quarkus] (main) Installed features: [cdi, kubernetes, rest, smallrye-context-propagation, vertx]
115+
----
116+
117+
. Retrieve a list of services:
118+
+
119+
[source,shell,subs="+quotes",options="nowrap"]
120+
----
121+
oc get svc
122+
----
123+
+
124+
[source,shell,subs="+quotes",options="nowrap"]
125+
----
126+
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
127+
openshift-helloworld ClusterIP 172.30.64.57 <none> 80/TCP 14m
128+
----
129+
130+
. Get a URL to test your application.
131+
+
132+
[NOTE]
133+
====
134+
To create an {RHOSSHORT} route, ensure you have specified `quarkus.openshift.route.expose=true` in the `application.properties` file.
135+
====
136+
+
137+
[source,shell,subs="+quotes",options="nowrap"]
138+
----
139+
oc get routes
140+
----
141+
+
142+
[source,shell,subs="+quotes",options="nowrap"]
143+
----
144+
NAME HOST/PORT PATH SERVICES PORT TERMINATION WILDCARD
145+
openshift-helloworld openshift-helloworld-username-dev.apps.sandbox-m2.ll9k.p1.openshiftapps.com openshift-helloworld http None
146+
----
147+
+
148+
[NOTE]
149+
====
150+
Be aware that the route is now listening on port 80 and no longer at port 8080.
151+
====
152+
+
153+
You can test the application demonstrated in this example with a web browser or a terminal by using `curl` and the complete URL output from `oc get routes`, that is, "\http://openshift-helloworld-username-dev.apps.sandbox-m2.ll9k.p1.openshiftapps.com".
154+
+
155+
For example: `curl \http://openshift-helloworld-username-dev.apps.sandbox-m2.ll9k.p1.openshiftapps.com`.
156+
157+
158+
== Configuration Reference
159+
160+
include::{generated-dir}/config/quarkus-kubernetes_quarkus.openshift.adoc[opts=optional, leveloffset=+1]

0 commit comments

Comments
 (0)