The Source-to-Image (S2I) tool injects application source code into a container image and the final product is a new and ready-to-run container image that incorporates the builder image and built source code. The S2I tool can be installed on your local machine without OKD from the repository.
The S2I tool is a very powerful tool to test and verify your application and images locally before using them on OKD.
Identify the builder image that is needed for the application. Red Hat offers multiple builder images for different languages including Python, Ruby, Perl, PHP, and Node.js. Other images are available from the community space.
S2I can build images from source code in a local file system or from a Git repository. To build a new container image from the builder image and the source code:
$ s2i build <source-location> <builder-image-name> <output-image-name>
<source-location>can either be a Git repository URL or a directory to source code in a local file system.
Test the built image with the Docker daemon:
$ docker run -d --name <new-name> -p <port-number>:<port-number> <output-image-name> $ curl localhost:<port-number>
Push the new image to the OpenShift registry.
Create a new application from the image in the OpenShift registry using the
$ oc new-app <image-name>