Openwhisk: Feature request: Ruby runtime

Created on 19 Mar 2017  路  3Comments  路  Source: apache/openwhisk


Make Ruby a first-class citizen in OpenWhisk.

enhancement runtime

Most helpful comment

hello.rb

def main( input )                                                                                                               
  if name = input[ 'name' ]                                                                                                     
    { 'greeting' => "Hello #{name}!" }                                                                                          
  else                                                                                                                          
    { 'greeting' => 'Hello stranger!' }                                                                                         
  end                                                                                                                           
end      

Dockerfile

FROM ruby:2.4.1                                                                                                                 
RUN  gem install \                                                                                                              
       bundler \                                                                                                                
       sinatra \                                                                                                                
       activesupport \                                                                                                          
       yaml-ostruct \                                                                                                           
       couchrest \                                                                                                              
       jwt        

build.gradle

ext.dockerImageName = 'rubyAction'                                                                                              
apply from: '../../gradle/docker.gradle'                                                                                        
distDocker.dependsOn ':core:actionProxy:distDocker'

All 3 comments

A few key steps to get this ball rolling:

  • [ ] a hello.rb script that takes in a dict (hash ?) and returns a modified dict
  • [ ] a Dockerfile that builds a reasonable Ruby version
  • [ ] a related build.gradle to drive the docker build

If we could get those three things done, we could evaluate the feasibility of this request.

hello.rb

def main( input )                                                                                                               
  if name = input[ 'name' ]                                                                                                     
    { 'greeting' => "Hello #{name}!" }                                                                                          
  else                                                                                                                          
    { 'greeting' => 'Hello stranger!' }                                                                                         
  end                                                                                                                           
end      

Dockerfile

FROM ruby:2.4.1                                                                                                                 
RUN  gem install \                                                                                                              
       bundler \                                                                                                                
       sinatra \                                                                                                                
       activesupport \                                                                                                          
       yaml-ostruct \                                                                                                           
       couchrest \                                                                                                              
       jwt        

build.gradle

ext.dockerImageName = 'rubyAction'                                                                                              
apply from: '../../gradle/docker.gradle'                                                                                        
distDocker.dependsOn ':core:actionProxy:distDocker'

Fixed by #3725

Was this page helpful?
0 / 5 - 0 ratings