Deploy your Padrino app on anynines in 3 steps

Matthias Günther (@wikimatze) runs vimberlin, a gathering for Vim-enthusiasts and is currently writing on his Padrino Book. As such he teamed up with our support team to write a How-to guide for Padrino deployments on anynines.

Padrino is a Ruby framework built upon the Sinatra web library, created to make it easy to code more advanced web applications while still sticking to what makes Sinatra great (like its simplicity). Think: creating a standard library of tools, helpers and functions that ready your Sinatra apps for increasingly complex requirements.

Fun fact: one of the teams applying to Rails Girls Summer of Code this year, proposed to work on Padrino over the course of the summer.

1. Get started with Padrino

To get started with Padrino, run the following commands:
$ gem install padrino
$ padrino g project padrino-hello-world-anynines
$ cd padrino-hello-world-anynines
$ bundle
$ padrino start

Yep, that’s it. The next part is to create a route in app/app.rb:
module PadrinoHelloWorldAnynines
class App < Padrino::Application
...
get "/" do
"Hello Padrino on anynines"
end
end
end

In case you can’t wait to see some code for a ‘Hello World’ program, check out my example app (with MySQL support) on GitHub. You can see the running app on padrino-hello-world-anynines-mysql.de.a9sapp.eu.

2. Get started with anynines

Let’s fetch the example app and deploy it to anynines, shall we?
$ git clone https://github.com/matthias-guenther/padrino-hello-world-anynines-mysql.git
$ cd padrino-hello-world-anynines-mysql/

Before you start it’s necessary to install Ruby 1.9.3 (or higher) and the a9s gem. After you’ve installed Ruby, go to your command line and install the a9s gem which downloads the needed gems for interacting with the anynines system:
$ gem install a9s

Next you will need to select the anynines api endpoint as target and authenticate with the auth service using your user credentials:
$ cf target https://api.de.a9s.eu
$ cf login --email [your@email] --password [yourpassword]

Push the application and follow the CLI to define your project space(s) and services – MySQL in our case:
$ cf push

anynines needs to have a Gemfile.lock for Padrino projects.

3. Use MySQL for your app

Make sure MySQL is in $PATH. If it isn’t, you will need to install a proper MySQL client like mysql-client-5.5 for Ubuntu.

Define the port in database.rb:

ActiveRecord::Base.configurations[:production] = {
:adapter => 'mysql2',
:encoding => 'utf8',
:reconnect => true,
:database => JSON.parse(ENV["VCAP_SERVICES"])["mysql-5.5"].first['credentials']['name'],
:pool => 5,
:username => JSON.parse(ENV["VCAP_SERVICES"])["mysql-5.5"].first['credentials']['username'],
:password => JSON.parse(ENV["VCAP_SERVICES"])["mysql-5.5"].first['credentials']['password'],
:host => JSON.parse(ENV["VCAP_SERVICES"])["mysql-5.5"].first['credentials']['hostname'],
:port => JSON.parse(ENV["VCAP_SERVICES"])["mysql-5.5"].first['credentials']['port']
}

Run your migrations:

cf push --command 'RACK_ENV=production bundle exec rake ar:migrate'

Finally, run the start command:

cf push --command 'RACK_ENV=production bundle exec padrino start -p $PORT -h $VCAP_APP_HOST'

If you now call padrino-hello-world-anynines-mysql.de.a9sapp.eu/ you can see the “Hello Matthias Günther, I know your email: matthias@wikimatze.de” in your browser. Scary, I know.

Enjoy developing with Padrino!

Meet you ‘in the wild’ at the Berlin Web Week!

Next week Berlin will host the Web Week, with re:publica, the Media Convention, Heureka, tools, droidcon, the API Days, the LinuxTag (where our own Julian Weber will give a talk) and many other tech related events.

Earlier today we were present at the press briefing for re:publica (and the Media Convention) and we are excited to see the conference’ main themes evolve into data protection topics. Re:publica, taking place May 6-8, aims to educate the ‘digitale Gesellschaft’ (loosely translated: digital community) on net surveillance and how to protect your data from evil do-ers. (more…)

What is a Platform as a Service (or: PaaS) really?

I get the question from the title a lot since I started working at anynines. Which is fair enough, with the Everything as a Service trend, one easily gets the terminology confused. The extension as a service is used in many core components of cloud computing including communication, infrastructure, data and platforms (there we are!). Let’s look at a few of those in more detail.

Infrastructure as a Service

Providers of Infrastructure as a Service (IaaS) offer computers – physical or more often virtual machines – and other resources. A hypervisor – powered by OpenStack in our case – runs the virtual machines (VMs). IaaS clouds often offer additional resources such as a virtual-machine disk image library, raw (block) and file-based storage, firewalls, load balancers, IP addresses, virtual local area networks (VLANs), and software bundles on-demand from their large pools installed in data centers.


Quite possibly funniest IaaS reference in a Twitter bio ever.

Why would you use IaaS rather than ‘bare metal’? Well, cloud providers typically bill IaaS services on a utility basis (where the cost reflects the amount of actual resources allocated and consumed), which is oftentimes cheaper. (more…)