### Source to Image

The {wildfly-camel} https://hub.docker.com/r/wildflyext/wildfly-camel/[Docker image,window=_blank] is capable of performing https://docs.openshift.org/latest/architecture/core_concepts/builds_and_image_streams.html#source-build[Source-To-Image,window=_blank] builds.

This enables you to build reproducible images from source.

#### Example S2I build

First you'll need to download and install the S2I tooling from https://github.com/openshift/source-to-image[here,window=_blank].

Then you can build and run a Docker image from source. For example, to build the {wildfly-camel} CDI quickstart:

[source,options="nowrap",subs="attributes"]
$ s2i build https://github.com/wildfly-extras/wildfly-camel-examples.git -r {version} --context-dir camel-cdi wildflyext/wildfly-camel:{version} wildfly-camel-example-cdi
$ docker run -ti -p 8080:8080 wildfly-camel-example-cdi

From a remote client, you should now be able to access the service like this

http://{ec2-pub-ip}:8080/example-camel-cdi?name=Kermit[,window=_blank]

 Hello Kermit

#### S2I with OpenShift Origin

{wildfly-camel} provides an OpenShift builder image, which enables you to do a source to image in OpenShift.

First add the {wildfly-camel} S2I ImageStream and the application template.

[source,bash,options="nowrap"]
----
$ oc project # Check into which project you are importing the image stream and the template
Using project "myproject" from context named "minishift" on server "https://192.168.42.188:8443".
$ oc apply -f http://wildfly-extras.github.io/wildfly-camel/sources/wildfly-camel-imagestream.json
$ oc create -f http://wildfly-extras.github.io/wildfly-camel/sources/wildfly-camel-application-template.json
----

In the OpenShift web console, go to the project where you imported the image stream and the template. When you select
'Add to Project -> Select from Project' in the top right corner you should see a new catalog item named 'Wildfly Camel'.
Choose this option, then provide the required parameters.

image::wildfly-camel-s2i-builder01.png[]

To build the latest release of the {wildfly-camel} CDI example you would enter (leaving the rest of the parameters
unchanged):

[cols="1,2",width="80%"]
|=======
|**Application Name**| camel-cdi
|**Base Image ImageStream Namespace**| The name of the project where you imported the WildFly Camel image stream the previous step; e.g. `myproject`
|**Git Repository URL**| https://github.com/wildfly-extras/wildfly-camel-examples.git
|**Git Reference**| {version}
|**Context Directory**| camel-cdi
|=======

Click 'Create' to start the build process.

You'll then be able to monitor your application S2I build and deployment in OpenShift. Eventually you should see your application with 1 pod running.

image::wildfly-camel-s2i-builder02.png[]

Then to access the application you can browse to the route endpoint URL. For example:

http://camel-cdi-wildfly-camel.{ec2-pub-ip}.xip.io/example-camel-cdi?name=Kermit[,window=_blank]

 Hello Kermit


