// Module included in the following assemblies:
//
// * openshift_images/using_images/using-images-source-to-image.adoc
// * Unused. Can be removed by 4.9 if still unused. Request full peer review for the module if it’s used.

[id="images-using-images-s2i-ruby-hot-deploying_{context}"]
== Hot deploying for Ruby

Hot deployment allows you to quickly make and deploy changes to your application without having to generate a new source-to-image (S2I) build. The method for enabling hot deployment in this image differs based on the application type.

*Ruby on Rails applications*

.Procedure

For Ruby on Rails application, run the built Rails application with the `RAILS_ENV=development` environment variable passed to the running pod.

* For an existing deployment configuration, you can use the `oc set env` command:
+
[source,terminal]
----
$ oc set env dc/rails-app RAILS_ENV=development
----

*Other Types of Ruby applications such as Sinatra or Padrino*

For other types of Ruby applications, your application must be built with a gem that can reload the server every time a change to the source code is made inside the running container. Those gems are:

* Shotgun
* Rerun
* Rack-livereload

To be able to run your application in development mode, you must modify the S2I `run` script so that the web server is launched by the chosen gem, which checks for changes in the source code.

After you build your application image with your version of the S2I `run` script, run the image with the `RACK_ENV=development` environment variable. For example, you can use the `oc new-app` command. You can use the `oc set env` command to update environment variables of existing objects.

[WARNING]
====
You should only use this option while developing or debugging. It is not recommended to turn this on in your production environment.
====

.Procedure

. To change your source code in a running pod, use the `oc rsh` command to enter the container:
+
[source,terminal]
----
$ oc rsh <pod_id>
----

After you enter into the running container, your current directory is set to `/opt/app-root/src`, where the source code is located.
