github.com/iron-io/functions@v0.0.0-20180820112432-d59d7d1c40b2/examples/hello/ruby/README.md (about)

     1  ## Quick Example for a Ruby Function (4 minutes)
     2  
     3  This example will show you how to test and deploy a Ruby function to IronFunctions.
     4  
     5  ```sh
     6  # create your func.yaml file
     7  fn init <YOUR_DOCKERHUB_USERNAME>/hello
     8  # install dependencies, we need the json gem to run this
     9  docker run --rm -it -v ${pwd}:/worker -w /worker iron/ruby:dev bundle install --standalone --clean
    10  # build the function
    11  fn build
    12  # test it
    13  cat hello.payload.json | fn run
    14  # push it to Docker Hub
    15  fn push
    16  # Create a route to this function on IronFunctions
    17  fn routes create myapp /hello
    18  ```
    19  
    20  Now surf to: http://localhost:8080/r/myapp/hello
    21  
    22  ## Dependencies
    23  
    24  Create a [Gemfile](http://bundler.io/gemfile.html) file in your function directory, then run:
    25  
    26  ```sh
    27  docker run --rm -it -v ${pwd}:/worker -w /worker iron/ruby:dev bundle install --standalone --clean
    28  ```
    29  
    30  Ruby doesn't pick up the gems automatically, so you'll have to add this to the top of your `func.rb` file:
    31  
    32  ```ruby
    33  require_relative 'bundle/bundler/setup'
    34  ```
    35  
    36  Open `func.rb` to see it in action.
    37  
    38  To update dependencies:
    39  
    40  ```sh
    41  docker run --rm -it -v ${pwd}:/worker -w /worker iron/ruby:dev bundle update
    42  # then install again to vendor them
    43  docker run --rm -it -v ${pwd}:/worker -w /worker iron/ruby:dev bundle update
    44  ```