Customizing source-to-image images
To modify the default assemble and run script behavior in OpenShift Container Platform, you can customize source-to-image (S2I) builder images. You can adapt S2I builders to meet your specific application requirements when the default scripts are not suitable.
Invoking scripts embedded in an image
To extend builder image behavior while preserving supported script logic and upgrade compatibility in OpenShift Container Platform, you can start embedded S2I image scripts by creating wrapper scripts. These wrapper scripts run custom logic and then call the default scripts from the image.
-
Inspect the value of the
io.openshift.s2i.scripts-urllabel to determine the location of the scripts inside of the builder image:$ podman inspect --format='{{ index .Config.Labels "io.openshift.s2i.scripts-url" }}' wildfly/wildfly-centos7Example outputimage:///usr/libexec/s2i -
Create a script that includes an invocation of one of the standard scripts wrapped in other commands:
.s2i/bin/assemblescript#!/bin/bash echo "Before assembling" /usr/libexec/s2i/assemble rc=$? if [ $rc -eq 0 ]; then echo "After successful assembling" else echo "After failed assembling" fi exit $rcThis example shows a custom assemble script that prints the message, runs the standard assemble script from the image, and prints another message depending on the exit code of the assemble script.
Important
When wrapping the run script, you must use
execfor invoking it to ensure signals are handled properly. The use ofexecalso precludes the ability to run additional commands after invoking the default image run script..s2i/bin/runscript#!/bin/bash echo "Before running application" exec /usr/libexec/s2i/run