What are the options to execute CLI commands at build time in JBoss EAP 7 in OCP images

Solution Verified - Updated

Environment

  • Red Hat Enterprise Application Platform
    • 7.x
    • builder image
  • Red hat OpenShift Container Platform (OCP)
    • 4.x <-- not runtime

Issue

  • What are the options to execute CLI commands at build time in JBoss EAP 7 in OCP images?
  • Build time options for executing CLI commands at build time in JBoss EAP 7 in OCP images

Resolution

The alternatives for CLI command execution on the build seem to be the ones below - depending on the method for building:

MethodApproach
Dockerfile buildCall the jboss-cli at build time in the Dockerfile: RUN $JBOSS_HOME/bin/jboss-cli.sh --file=/tmp/actions.cli <-- docker execution
eap-maven-plugin buildConfigure the eap-maven-plugin in your pom to execute CLI scripts during build.
S2I buildsS2I_IMAGE_SOURCE_MOUNTS this is an extensions env variable, have an extensions directory in the source project, in the extensions directory have a CLI script file (script.cli) and an install.sh script that calls the CLI:

Example Dockerfile build

The below example builds an EAP 7 image with actions.cli, which is passed on the build:

FROM registry.redhat.io/jboss-eap-7/eap74-openjdk11-openshift-rhel8 as BUILDER

ENV GALLEON_PROVISION_LAYERS=""
ENV GALLEON_PROVISION_DEFAULT_FAT_SERVER=true
ENV CONFIG_IS_FINAL=true

RUN /usr/local/s2i/assemble

COPY lib/actions.cli /tmp/actions.cli
RUN $JBOSS_HOME/bin/jboss-cli.sh --file=/tmp/actions.cli

# From EAP 7.4 runtime image, copy the builder's server & add the war
FROM registry.redhat.io/jboss-eap-7/eap74-openjdk11-runtime-openshift-rhel8 as RUNTIME
USER root
COPY --from=BUILDER --chown=jboss:root $JBOSS_HOME $JBOSS_HOME

RUN chmod -R ug+rwX $JBOSS_HOME

USER jboss
CMD $JBOSS_HOME/bin/openshift-launch.sh

Root Cause

There are alternatives for configuration chagne at runtime and build time. The alternatives for runtime are discussed on What are the options to use a custom runtime JBoss EAP 7 configurations in OCP 4, whereas the build time alternatives are discussed in this article.

Components
Tags

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.