Commit 31a45a94 authored by Kirill Smelkov's avatar Kirill Smelkov

helloworld & helloweb: Ruby version

To illustrate how to build Ruby software, let's add helloweb-ruby
component and integrate it into helloworld SR as a service.

helloweb-ruby installation is a bit tricky, because we do not have it
initially as a released gem, and have to build it with Bundler by hand.

Changes for integration into helloworld services infrastructure are
small, thanks for the "kind" rework we did in previous patch.

/cc @kazuhiko
parent 2b6c1e47
......@@ -2,9 +2,11 @@
[buildout]
extends =
../git/buildout.cfg
../ruby/buildout.cfg
parts =
helloweb-python
helloweb-ruby
# repository with examples
......@@ -12,7 +14,7 @@ parts =
recipe = slapos.recipe.build:gitclone
git-executable = ${git:location}/bin/git
repository = https://lab.nexedi.com/nexedi/helloweb.git
revision = 686dd5dd623728750ec30514173a7be36fab3a06
revision = 7f5e49a541ae7b51da034dcdf20b91b64f4fb0e9
location = ${buildout:parts-directory}/helloweb
......@@ -26,3 +28,53 @@ setup = ${helloweb-repository:location}/python/
recipe = zc.recipe.egg:scripts
eggs = ${helloweb-egg:egg}
scripts = helloweb=helloweb-python
# -*- ruby -*-
# if ruby program is represented as already-released gem, we can install it
# with `gem install ...` (via rubygemsrecipe).
#
# Alternatively if we need to
# install the program from source-checkout, the Ruby way is to use bundler,
# install program dependencies via it, and run the program itself via it.
#
# Since for helloweb.rb we have source checkout - we go the second - bundler way.
# bundler, that we'll use to install gems and run binaries (via `bundle exec ...`)
[bundler]
# rubygemsrecipe with fixed url and this way pinned rubygems version
recipe = rubygemsrecipe
url = https://rubygems.org/rubygems/rubygems-2.4.8.zip
ruby-location = ${ruby2.1:location}
ruby-executable = ${:ruby-location}/bin/ruby
gems = bundler==1.10.6
# bin installed here
bundle = ${buildout:bin-directory}/bundle
# install together with path to ruby enabled
# ( reason: rubygemsrecipe hardcodes PATH inside generated bin/* and it is
# impossible to adjust it later )
#
# bundle exec <smth> ; <smth> starts with `#!/usr/bin/env ruby` as rubygems
environment =
PATH = ${:ruby-location}/bin:%(PATH)s
[helloweb-ruby-bundle]
recipe = slapos.recipe.cmmi
path = ${helloweb-repository:location}/ruby/
configure-command = :
make-binary =
make-targets= cd ${:path} && ${bundler:bundle} install
[helloweb-ruby]
recipe = slapos.cookbook:wrapper
wrapper-path = ${buildout:bin-directory}/${:_buildout_section_name_}
environment =
BUNDLE_GEMFILE = ${helloweb-ruby-bundle:path}/Gemfile
command-line =
${bundler:bundle} exec sh -c 'helloweb.rb "$@"' ${:_buildout_section_name_}
......@@ -109,6 +109,7 @@ port = {{ port }}
# services instantiation
{{ hellowebsrv('python', 7777) }}
{{ hellowebsrv('ruby', 7778) }}
# register all services/promises to buildout parts
......
......@@ -21,6 +21,7 @@ parts =
# build helloweb programs
helloweb-python
helloweb-ruby
# Download instance.cfg.in (buildout profile used to deployment of instance),
......@@ -31,7 +32,7 @@ recipe = slapos.recipe.template:jinja2
template = ${:_profile_base_location_}/instance.cfg.in
rendered = ${buildout:directory}/instance.cfg
# MD5 checksum can be skipped for development (easier to develop), but must be filled for production
md5sum = dc11d4d87edda76189ddd88a35265f05
md5sum = be7f930921376b3c8eb51c975e24721f
mode = 0644
extensions = jinja2.ext.do
context =
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment