Skip to content

Commit ea3166e

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

File tree

1 file changed

+172
-0
lines changed

1 file changed

+172
-0
lines changed
Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
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+
30+
:prerequisites-no-graalvm:
31+
include::{includes}/prerequisites.adoc[]
32+
* Access to an OpenShift cluster (Minishift is a viable option)
33+
* OpenShift CLI (Optional, only required for manual deployment)
34+
35+
== Procedure
36+
37+
. Set the Docker build strategy in your `application.properties` configuration file:
38+
+
39+
[source, properties]
40+
----
41+
quarkus.openshift.build-strategy=docker
42+
----
43+
. Optional: Set the following properties in the `application.properties` file, as required by your environment:
44+
.. If you are using an untrusted certificate, configure the `KubernetesClient`:
45+
+
46+
[source,properties]
47+
----
48+
quarkus.kubernetes-client.trust-certs=true
49+
----
50+
.. Expose the service to create an {RHOSSHORT} route:
51+
+
52+
[source,properties]
53+
----
54+
quarkus.openshift.route.expose=true
55+
----
56+
.. Set the path to your custom Dockerfile:
57+
+
58+
[source,properties,subs="attributes+,+quotes"]
59+
----
60+
quarkus.openshift.jvm-dockerfile=<path_to_your_dockerfile>
61+
----
62+
The following example shows the path to the `Dockerfile.custom-jvm`:
63+
+
64+
[source,properties]
65+
----
66+
quarkus.openshift.jvm-dockerfile=src/main/resources/Dockerfile.custom-jvm
67+
----
68+
69+
70+
. Package and deploy your Quarkus application to the current OpenShift project:
71+
+
72+
[source,shell,subs="attributes+,+quotes"]
73+
----
74+
./mvnw clean package -Dquarkus.openshift.deploy=true
75+
----
76+
77+
78+
== Verification
79+
80+
81+
The verification steps and related terminal outputs are demonstrated on the `openshift-helloworld` example application.
82+
83+
84+
. Display the list of pods associated with your current OpenShift project:
85+
+
86+
[source,shell,subs="+quotes",options="nowrap"]
87+
----
88+
oc get pods
89+
----
90+
+
91+
[source,shell,subs="+quotes",options="nowrap"]
92+
----
93+
NAME READY STATUS RESTARTS AGE
94+
openshift-helloworld-1-build 0/1 Completed 0 11m
95+
openshift-helloworld-1-deploy 0/1 Completed 0 10m
96+
openshift-helloworld-1-gzzrx 1/1 Running 0 10m
97+
----
98+
99+
100+
101+
102+
. 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.
103+
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:
104+
+
105+
[source,shell,subs="+quotes",options="nowrap"]
106+
----
107+
oc logs -f _openshift-helloworld-1-gzzrx_
108+
----
109+
+
110+
[source,shell,subs=attributes+]
111+
----
112+
Starting the Java application using /opt/jboss/container/java/run/run-java.sh ...
113+
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
114+
__ ____ __ _____ ___ __ ____ ______
115+
--/ __ \/ / / / _ | / _ \/ //_/ / / / __/
116+
-/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \
117+
--\___\_\____/_/ |_/_/|_/_/|_|\____/___/
118+
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
119+
2024-09-17 10:23:25,281 INFO [io.quarkus] (main) Profile prod activated.
120+
2024-09-17 10:23:25,281 INFO [io.quarkus] (main) Installed features: [cdi, kubernetes, rest, smallrye-context-propagation, vertx]
121+
----
122+
123+
124+
125+
126+
. Retrieve a list of services:
127+
+
128+
[source,shell,subs="+quotes",options="nowrap"]
129+
----
130+
oc get svc
131+
----
132+
+
133+
[source,shell,subs="+quotes",options="nowrap"]
134+
----
135+
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
136+
openshift-helloworld ClusterIP 172.30.64.57 <none> 80/TCP 14m
137+
----
138+
139+
140+
141+
142+
. Get a URL to test your application.
143+
+
144+
[NOTE]
145+
====
146+
To create an {RHOSSHORT} route, ensure you have specified `quarkus.openshift.route.expose=true` in the `application.properties` file.
147+
====
148+
+
149+
[source,shell,subs="+quotes",options="nowrap"]
150+
----
151+
oc get routes
152+
----
153+
+
154+
[source,shell,subs="+quotes",options="nowrap"]
155+
----
156+
NAME HOST/PORT PATH SERVICES PORT TERMINATION WILDCARD
157+
openshift-helloworld openshift-helloworld-username-dev.apps.sandbox-m2.ll9k.p1.openshiftapps.com openshift-helloworld http None
158+
----
159+
+
160+
[NOTE]
161+
====
162+
Be aware that the route is now listening on port 80 and no longer at port 8080.
163+
====
164+
+
165+
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".
166+
+
167+
For example: `curl \http://openshift-helloworld-username-dev.apps.sandbox-m2.ll9k.p1.openshiftapps.com`.
168+
169+
170+
== Configuration Reference
171+
172+
include::{generated-dir}/config/quarkus-kubernetes_quarkus.openshift.adoc[opts=optional, leveloffset=+1]

0 commit comments

Comments
 (0)