commit 7cb999c0a9f1b531a22fe143215e16459e52b2e4 Author: Ben Parees Date: Fri Sep 11 00:18:43 2015 -0400 initial create diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..18e0256 --- /dev/null +++ b/Gemfile @@ -0,0 +1,3 @@ +source 'https://rubygems.org' +gem 'rack' + diff --git a/README.md b/README.md new file mode 100644 index 0000000..e1942f9 --- /dev/null +++ b/README.md @@ -0,0 +1,69 @@ +Ruby Sample App on OpenShift +============================ + +This is a basic ruby application for OpenShift v3 that you can use as a starting point to develop your own application and deploy it on an [OpenShift](https://github.com/openshift/origin) cluster. + +If you'd like to install it, follow [these directions](https://github.com/openshift/ruby-ex/blob/master/README.md#installation). + +The steps in this document assume that you have access to an OpenShift deployment that you can deploy applications on. + +###Installation: +These steps assume your OpenShift deployment has the default set of ImageStreams defined. Instructions for installing the default ImageStreams are available [here](http://docs.openshift.org/latest/admin_guide/install/first_steps.html). Instructions for installing the default ImageStreams are available [here](http://docs.openshift.org/latest/admin_guide/install/first_steps.html). If you are defining the set of ImageStreams now, remember to pass in the proper cluster-admin credentials and to create the ImageStreams in the 'openshift' namespace. + +1. Fork a copy of [ruby-ex](https://github.com/openshift/ruby-ex) +2. Add a Ruby application from your new repository: + + $ oc new-app openshift/ruby-20-centos7~https://github.com/< yourusername >/ruby-ex + +3. A build should start immediately. To run another build, run: + + $ oc start-build ruby-ex + +4. Once the build is running, watch your build progress + + $ oc build-logs ruby-ex-1 + +5. Wait for ruby-ex pods to start up (this can take a few minutes): + + $ oc get pods -w + + + Sample output: + + NAME READY STATUS RESTARTS AGE + ruby-ex-1-build 0/1 ExitCode:0 0 2m + ruby-ex-1-deploy 1/1 Running 0 25s + ruby-ex-1-hrek2 1/1 Running 0 17s + + +6. Check the IP and port the ruby-ex service is running on: + + $ oc get svc + + + Sample output: + + NAME CLUSTER_IP EXTERNAL_IP PORT(S) SELECTOR AGE + ruby-ex 172.30.97.209 8080/TCP deploymentconfig=ruby-ex 2m + + +In this case, the IP for ruby-ex is 172.30.97.209 and it is on port 8080. +*Note*: you can also get this information from the web console. + + +###Debugging Unexpected Failures + +Review some of the common tips and suggestions [here](https://github.com/openshift/origin/blob/master/docs/debugging-openshift.md). + +###Adding Webhooks and Making Code Changes +Since OpenShift V3 does not provide a git repository out of the box, you can configure your github repository to make a webhook call whenever you push your code. + +1. From the console navigate to your project +2. Click on Browse > Builds +3. From the view for your Build click on the link to display your GitHub webhook and copy the url. +4. Navigate to your repository on GitHub and click on repository settings > webhooks +5. Paste your copied webhook url provided by OpenShift - Thats it! +6. After you save your webhook, if you refresh your settings page you can see the status of the ping that Github sent to OpenShift to verify it can reach the server. + +###License +This code is dedicated to the public domain to the maximum extent permitted by applicable law, pursuant to [CC0](http://creativecommons.org/publicdomain/zero/1.0/). diff --git a/config.ru b/config.ru new file mode 100755 index 0000000..a709f06 --- /dev/null +++ b/config.ru @@ -0,0 +1,304 @@ +require 'rack/lobster' + +map '/health' do + health = proc do |env| + [200, { "Content-Type" => "text/html" }, ["1"]] + end + run health +end + +map '/lobster' do + run Rack::Lobster.new +end + +map '/' do + welcome = proc do |env| + [200, { "Content-Type" => "text/html" }, [< + + + + + Welcome to OpenShift + + + + + + + +
+
+

Welcome to your Ruby application on OpenShift

+
+ + +
+
+
+

Deploying code changes

+

+ The source code for this application is available to be forked from the OpenShift GitHub repository. + You can configure a webhook in your repository to make OpenShift automatically start a build whenever you push your code: +

+ +
    +
  1. From the Web Console homepage, navigate to your project
  2. +
  3. Click on Browse > Builds
  4. +
  5. From the view for your Build click on the button to copy your GitHub webhook
  6. +
  7. Navigate to your repository on GitHub and click on repository settings > webhooks
  8. +
  9. Paste your webhook URL provided by OpenShift — that's it!
  10. +
+

After you save your webhook, if you refresh your settings page you can see the status of the ping that Github sent to OpenShift to verify it can reach the server.

+

Note: adding a webhook requires your OpenShift server to be reachable from GitHub.

+ +

Working in your local Git repository

+

If you forked the application from the OpenShift GitHub example, you'll need to manually clone the repository to your local system. Copy the application's source code Git URL and then run:

+ +
$ git clone <git_url> <directory_to_create>
+
+# Within your project directory
+# Commit your changes and push to OpenShift
+
+$ git commit -a -m 'Some commit message'
+$ git push
+ +

After pushing changes, you'll need to manually trigger a build if you did not setup a webhook as described above.

+
+
+
+ +

Managing your application

+ +

Documentation on how to manage your application from the Web Console or Command Line is available at the Developer Guide.

+ +

Web Console

+

You can use the Web Console to view the state of your application components and launch new builds.

+ +

Command Line

+

With the OpenShift command line interface (CLI), you can create applications and manage projects from a terminal.

+ +

Development Resources

+ + + +
+
+ + +
+ + + + +WELCOME_CONTENTS + ]] + end + run welcome +end