Running JBoss CLI commands on extended JBoss EAP 7 OpenShift Image

Solution Verified - Updated

Environment

  • Red Hat Openshift Container Platform (OCP)
    • 3.7
    • 3.9
    • 3.11
  • Red Hat Enterprise Application Platform (EAP)
    • 7
  • JBoss EAP 7 OpenShift Images
  • Extending the image with jboss-cli commands

Issue

  • Running jboss-cli commands from Dockerfile causes deployment / startup to fail.

Resolution

This can be resolved by using the configure extensions mechanism for running additional post configuration jboss-cli scripts.

Example Dockerfile project directory:

├── Dockerfile
├── extensions
│   ├── actions.cli
│   ├── postconfigure.sh

Dockerfile contents:

# Imagem EAP 7.4.4
FROM registry.redhat.io/jboss-eap-7/eap74-openjdk8-openshift-rhel7:7.4.4
RUN mkdir /opt/eap/extensions
COPY extensions/actions.cli /opt/eap/extensions
COPY extensions/postconfigure.sh /opt/eap/extensions
USER root
RUN chmod 774 /opt/eap/extensions/*.sh
USER jboss
CMD ["/opt/eap/bin/openshift-launch.sh"]

The file actions.cli is a jboss-cli script which includes custom additional configuration for the JBoss Server. The contents would have this structure:

embed-server --std-out=echo  --server-config=standalone-openshift.xml 
<commands>
quit

Finally, the postconfigure.sh script will take case of executing the jboss-cli script. Its contents would be:

$JBOSS_HOME/bin/jboss-cli.sh --file=/opt/eap/extensions/actions.cli

Root Cause

There are markers in the standalone-openshift.xml configuration file that are formatted as comments, and these markers are used by the scripts during the deployment of the server. Executing jboss-cli commands will cause a rewrite of the XML file, removing any comment blocks. CLI commands must, therefore, be run after tag replacement has completed.

Category

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.