Openshift DIY Ruby 1.9.3 Rails 3.2.x

Por ahora el enlace:

rhc-create-app -a [appname] -t diy-0.1 -l [email] -p [password]
$ rhc domain show

User Info
=========
Namespace: gomix
  RHLogin: ggomix

Application Info
================
eeb3
    Framework: diy-0.1
     Creation: 2012-06-28T13:48:22-04:00
         UUID: df6ea077b6444eecb88d69e324ab0367
      Git URL: ssh://df6ea077b6444eecb88d69e324ab0367@eeb3-gomix.rhcloud.com/~/git/eeb3.git/
   Public URL: http://eeb3-gomix.rhcloud.com/

 Embedded: 
      None
$ ssh df6ea077b6444eecb88d69e324ab0367@eeb3-gomix.rhcloud.com

    *********************************************************************

    You are accessing a service that is for use only by authorized users.  
    If you do not have authorization, discontinue use at once. 
    Any use of the services is subject to the applicable terms of the 
    agreement which can be found at: 
    https://openshift.redhat.com/app/legal

    *********************************************************************

    Welcome to OpenShift shell

    This shell will assist you in managing OpenShift applications.

    !!! IMPORTANT !!! IMPORTANT !!! IMPORTANT !!!
    Shell access is quite powerful and it is possible for you to
    accidentally damage your application.  Proceed with care!
    If worse comes to worst, destroy your application with 'rhc app destroy'
    and recreate it
    !!! IMPORTANT !!! IMPORTANT !!! IMPORTANT !!!

    Type "help" for more info.

[eeb3-gomix.rhcloud.com ~]\> 

Descarga instalación rvm

[eeb3-gomix.rhcloud.com ~]\> cd $OPENSHIFT_DATA_DIR

Antes de hacer el paso siguiente a lo ciego, pongo el script utilizado aquí.

#!/usr/bin/env bash

libyaml_package="yaml-0.1.4" 
libyaml_url="http://pyyaml.org/download/libyaml/${libyaml_package}.tar.gz" 
rvm_installer="https://raw.github.com/xiy/rvm-openshift/master/binscripts/rvm-installer" 

echo "=== Are we in the data path...?" 
if [[ ! ${pwd} == ${OPENSHIFT_DATA_DIR} ]]; then
  cd ${OPENSHIFT_DATA_DIR}
fi

echo "=== Getting ${libyaml_url}..." 
wget ${libyaml_url} & 
wait $!
tar zxvf ${libyaml_package}.tar.gz &
wait $!
cd ${libyaml_package}

if [ ! -d "${OPENSHIFT_DATA_DIR}/.rvm/usr" ]; then
  mkdir ${OPENSHIFT_DATA_DIR}/.rvm/usr
fi

echo "=== Building ${libyaml_package}..." 
./configure --prefix=${OPENSHIFT_DATA_DIR}/.rvm/usr &
wait $!

make && make install &
wait $!

echo "=== Installing RVM and Ruby 1.9.3..." 
curl -L ${rvm_installer} | bash -s master --ruby &
wait $!

echo "=== ALL DONE ===" 
echo "=== NOTE: You MUST run the 'source $OPENSHIFT_DATA_DIR/.rvm/scripts/rvm' command whenever you wish to use RVM!" 

Ahora si lo corremos.

[eeb3-gomix.rhcloud.com ~]\> curl -L https://raw.github.com/xiy/rvm-openshift/master/binscripts/install-rvm-openshift.sh | bash -s
...

Esto descargará los fuentes de libyaml-0.1.4 y lo compila, descarga e instala una versión de RVM (??), igualmente instala la última versión estable de Ruby (1.9.3-p125).

...
Creating alias default for ruby-1.9.3-p125.
Recording alias default for ruby-1.9.3-p125.
Creating default links/files

  * To start using RVM you need to run `source /var/lib/stickshift/df6ea077b6444eecb88d69e324ab0367/app-root/data//.rvm/scripts/rvm`
    in all your open shell windows, in rare cases you need to reopen all shell windows.
=== ALL DONE ===
=== NOTE: You MUST run the 'source /var/lib/stickshift/df6ea077b6444eecb88d69e324ab0367/app-root/data//.rvm/scripts/rvm' command whenever you wish to use RVM

¿Por ahora la pregunta es para qué RVM si sólo voy a tener una vm Ruby?

Algunos datos

Directorios de instalación.

[eeb3-gomix.rhcloud.com bin]\> ./ruby -v
ruby 1.9.3p125 (2012-02-16 revision 34643) [x86_64-linux]
[eeb3-gomix.rhcloud.com bin]\> pwd
/var/lib/stickshift/df6ea077b6444eecb88d69e324ab0367/app-root/data/.rvm/bin

Cuidado entonces de no confundir con:

[eeb3-gomix.rhcloud.com bin]\> ruby -v
ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]

que sigue siendo la instalación Ruby estandar en Openshift. De forma similar con el comando gem:

[eeb3-gomix.rhcloud.com bin]\> ./gem -v
1.8.24

[eeb3-gomix.rhcloud.com bin]\> gem -v
1.3.7

Gems instalados:

[eeb3-gomix.rhcloud.com bin]\> ./gem list

*** LOCAL GEMS ***

bundler (1.1.4)
rake (0.9.2.2)
rubygems-bundler (1.0.3)
rvm (1.11.3.4)

Más datos acerca de la instalación de rubygems.

[eeb3-gomix.rhcloud.com bin]\> ./gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 1.8.24
  - RUBY VERSION: 1.9.3 (2012-02-16 patchlevel 125) [x86_64-linux]
  - INSTALLATION DIRECTORY: /var/lib/stickshift/df6ea077b6444eecb88d69e324ab0367/app-root/data//.rvm/gems/ruby-1.9.3-p125
  - RUBY EXECUTABLE: /var/lib/stickshift/df6ea077b6444eecb88d69e324ab0367/app-root/data/.rvm/rubies/ruby-1.9.3-p125/bin/ruby
  - EXECUTABLE DIRECTORY: /var/lib/stickshift/df6ea077b6444eecb88d69e324ab0367/app-root/data//.rvm/gems/ruby-1.9.3-p125/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-linux
  - GEM PATHS:
     - /var/lib/stickshift/df6ea077b6444eecb88d69e324ab0367/app-root/data//.rvm/gems/ruby-1.9.3-p125
     - /var/lib/stickshift/df6ea077b6444eecb88d69e324ab0367/app-root/data//.rvm/gems/ruby-1.9.3-p125@global
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - http://rubygems.org/

Trabajando con RVM

[eeb3-gomix.rhcloud.com ~]\> source $OPENSHIFT_DATA_DIR/.rvm/scripts/rvm

[eeb3-gomix.rhcloud.com ~]\> ruby -v
ruby 1.9.3p125 (2012-02-16 revision 34643) [x86_64-linux]

[eeb3-gomix.rhcloud.com ~]\> gem -v
1.8.24

[eeb3-gomix.rhcloud.com ~]\> gem list

*** LOCAL GEMS ***

bundler (1.1.4)
rake (0.9.2.2)
rubygems-bundler (1.0.3)
rvm (1.11.3.4)

[eeb3-gomix.rhcloud.com ~]\> gem install rails -v'3.2.6' --no-rdoc --no-ri --verbose
...
...
GET http://production.cf.rubygems.org/gems/rails-3.2.6.gem
Fetching: rails-3.2.6.gem (100%)
200 OK
Successfully installed i18n-0.6.0
Successfully installed multi_json-1.3.6
Successfully installed activesupport-3.2.6
Successfully installed builder-3.0.0
Successfully installed activemodel-3.2.6
Successfully installed rack-1.4.1
Successfully installed rack-cache-1.2
Successfully installed rack-test-0.6.1
Successfully installed journey-1.0.4
Successfully installed hike-1.2.1
Successfully installed tilt-1.3.3
Successfully installed sprockets-2.1.3
Successfully installed erubis-2.7.0
Successfully installed actionpack-3.2.6
Successfully installed arel-3.0.2
Successfully installed tzinfo-0.3.33
Successfully installed activerecord-3.2.6
Successfully installed activeresource-3.2.6
Successfully installed mime-types-1.19
Successfully installed polyglot-0.3.3
Successfully installed treetop-1.4.10
Successfully installed mail-2.4.4
Successfully installed actionmailer-3.2.6
Successfully installed rack-ssl-1.3.2
Successfully installed thor-0.15.4
Successfully installed json-1.7.3
Successfully installed rdoc-3.12
Successfully installed railties-3.2.6
Successfully installed rails-3.2.6
29 gems installed

Aportes propios

El howto está basado en thin y me gustaría usar unicorn, no hay problema, es un gem, después de habilitar rvm:

[eeb3-gomix.rhcloud.com ~]\> gem install unicorn --verbose --no-rdoc --no-ri
...
Successfully installed kgio-2.7.4
Successfully installed raindrops-0.10.0
Successfully installed unicorn-4.3.1
3 gems installed

Primer test exitoso

No estoy usando gemsets de rvm.

[eeb3-gomix.rhcloud.com repo]\> source $OPENSHIFT_DATA_DIR/.rvm/scripts/rvm
[eeb3-gomix.rhcloud.com repo]\> cd $OPENSHIFT_REPO_DIR
[eeb3-gomix.rhcloud.com repo]\> unicorn -l $OPENSHIFT_INTERNAL_IP:$OPENSHIFT_INTERNAL_PORT
I, [2012-06-29T17:46:47.843302 #31393]  INFO -- : listening on addr=127.4.229.129:8080 fd=5
I, [2012-06-29T17:46:47.843734 #31393]  INFO -- : worker=0 spawning...
I, [2012-06-29T17:46:47.859334 #31415]  INFO -- : worker=0 spawned pid=31415
I, [2012-06-29T17:46:47.869920 #31415]  INFO -- : Refreshing Gem list
I, [2012-06-29T17:46:48.003558 #31393]  INFO -- : master process ready
I, [2012-06-29T17:47:06.723105 #31415]  INFO -- : worker=0 ready
200.84.61.182 - - [29/Jun/2012 17:47:41] "GET /rails/info/properties HTTP/1.0" 200 - 0.8236
...

Creando el proyecto en mi F17

$ git clone ssh://df6ea077b6444eecb88d69e324ab0367@eeb3-gomix.rhcloud.com/~/git/eeb3.git eeb3
$ cd eeb3