Example of using an Oracle JDBC datasource with the Red Hat JBoss EAP 7.1.x container for Openshift.
This example adds an Oracle JDBC driver as a module into the JBoss EAP image during an Openshift based source to image (s2i) build. A datasource is created at deploy time that uses the Oracle JDBC driver. This example assumes that the Oracle database is visible to pods via DNS alone.
NOTE: The Oracle JDBC driver is not provided with this example. Download the JDBC driver.
This repository provides a working reference which includes:
- An
.s2i
directory that includes anenvironment
file that setsCUSTOM_INSTALL_DIRECTORIES=extensions
. This is used by scripts provided in the JBoss EAP image to allow for customization to take place at pod deploy time. - An
extensions
directory that contains- The necessary module directory structure and module.xml file for the Oracle JDBC driver, as well as the Oracle JDBC driver file. The Oracle JDBC driver must be downloaded from Oracle.
- A
drivers.env
file that contains driver specific details. This example includes one driver, but multiple drivers can be included. Refer to the JBoss EAP for Openshift documentation for further details about the expected contents of this file. - An
install.sh
file that is executed during the Openshift s2i build process. This script takes care of installing the Oracle JDBC driver as a module into the JBoss EAP image (adding files to the image and updating the standalone-openshift.xml to include the driver config).
- A
configuration
directory that contains- A
datasources.env
file that provides all the specifics for the datasource. These settings are incorporated into the JBoss EAP configuration at pod deploy time. Multiple datasources can be provided, although this example uses only one. Refer to the JBoss EAP for Openshift documentation for further details about the expected contents of this file.
- A
- The environment variable
ENV_FILES
should be set in the deploymentconfig for this pod. The variable is set to the location/path of the.env
file for the datasources. For this example, the variable would be set like so:ENV_FILES=/opt/eap/standalone/configuration/*.env
- Example oc command to set this envrionment variable:
oc set env dc/the-deploymentconfig-name ENV_FILES=/opt/eap/standalone/configuration/*.env
- Example oc command to set this envrionment variable:
An Openshift build process clones this git repo into a build pod that performs a maven build of the example servlet. The example servlet artifact and Oracle JDBC driver are copied into the image during the build. The JBoss EAP configuration file (/opt/eap/standalone/configuration/standalone-openshift.xml
) that is provided in the JBoss EAP for Openshift image is updated to include the Oracle JDBC driver configuration. The Openshift build process produces a container image to be used directly in application pods or as a base image for application pods to derive from.
When the resulting container image is used to produce an application pod, the pod is configured at deploy time to include datasource settings provided by the datasources.env
file.