You can package a {productName} server and an application inside a bootable JAR. You can then run the application on a {productName} bare-metal platform or on a {productName} Openshift platform.
You can use the Maven plug-in to build a {productName} bootable JAR, and then you can run the application on a {productName} bare-metal platform. The following example demonstrates a quickstart pom.xml
file that contains a Maven profile named bootable-jar:
<profile>
<id>bootable-jar</id>
<build>
<plugins>
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-jar-maven-plugin</artifactId>
<configuration>
<feature-pack-location>wildfly@maven(org.jboss.universe:community-universe)#${version.server.bootable-jar}</feature-pack-location>
<layers>
<layer>jaxrs-server</layer>
<layer>microprofile-platform</layer>
</layers>
<plugin-options>
<jboss-fork-embedded>true</jboss-fork-embedded>
</plugin-options>
</configuration>
<executions>
<execution>
<goals>
<goal>package</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
-
Build the quickstart bootable JAR with the following command:
$ mvn clean package -Pbootable-jar
-
Run the quickstart application contained in the bootable JAR:
$ java -jar target/{artifactId}-bootable.jar
-
You can now interact with the quickstart application.
Note
|
After the quickstart application is deployed, the bootable JAR includes the application in the root context. Therefore, any URLs related to the application should not have the |
You can use the Maven plug-in to build a {productName} bootable JAR, and then you can run the application on a {productName} OpenShift platform. The following example demonstrates a quickstart pom.xml
file that contains a Maven profile named bootable-jar-openshift:
<profile>
<id>bootable-jar-openshift</id>
<build>
<plugins>
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-jar-maven-plugin</artifactId>
<configuration>
<feature-pack-location>wildfly@maven(org.jboss.universe:community-universe)#${version.server.bootable-jar}</feature-pack-location>
<layers>
<layer>jaxrs-server</layer>
<layer>microprofile-platform</layer>
</layers>
<plugin-options>
<jboss-fork-embedded>true</jboss-fork-embedded>
</plugin-options>
<cloud/>
</configuration>
<executions>
<execution>
<goals>
<goal>package</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.eclipse.jkube</groupId>
<artifactId>openshift-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>resource</goal>
<goal>build</goal>
</goals>
</execution>
</executions>
<configuration>
<enricher>
<config>
<jkube-service>
<type>NodePort</type>
</jkube-service>
</config>
</enricher>
</configuration>
</plugin>
</plugins>
</build>
</profile>
-
Log in to your OpenShift instance using the
oc login
command. -
Create a new project for the quickstart bootable JAR on OpenShift. For example:
$ oc new-project bootable-jar-project
-
Build the quickstart bootable JAR by issuing the following command. This command also completes the following tasks: creates the OpenShift deployment, service and route; generates a docker image and pushes the docker image to OpenShift; and runs the application.
$ mvn oc:deploy -Pbootable-jar-openshift
-
Get the URL of the route.
$ oc get route
-
Access the application in your web browser by using a URL. The URL is the value of the
HOST/PORT
field that was provided by theoc get route
command output. For example, the route of the URL for the quickstart used in this procedure ishttps://HOST_PORT_Value/
.
With the Eclipse JKube Maven plug-in, you can customize the generated OpenShift resources, such as deployments, routes, and so on, with YAML file extracts located in the src/main/jkube directory.
The route.yml
file, which is located in the src/main/jkube directory, is an example of a resource fragment. You can configure this resource fragment to change the Openshift application service route to use HTTPS:
spec: tls: insecureEdgeTerminationPolicy: Redirect termination: edge to: kind: Service name: {artifactId}
For more information about resource fragments, see the Eclipse JKube documentation.