Mailinglist Archive: yast-devel (43 mails)

< Previous Next >
[yast-devel] Howto: Web App Hosting With Heroku

I know Ruby but have little experience with web apps. If you're like me
then this article could be useful.

I needed a way to browse API documentation of multiple related code
repositories. (Yes, it's YaST).

I made a tool for that in the form of a web application. This was really
easy with the Sinatra framework.

First I ran it locally on my machine for myself. Then I ran it on a
machine in the company network for team mates to use. It was a VM that I
repurposed from a previous experiment. Then Pepa said it would be nice to
have it publicly accessible. How hard could that be?

I had heard that Heroku makes that sort of thing easy, and it turned to be

1. It's free. A low profile app, that only needs to run occasionally,
fits into their Free service plan. It sleeps after 30 minutes and
takes 10 seconds to wake up.

2. Easy to sign up. Enter your e-mail, pick a password. No other details

3. Easy app creation: pick the region (US or EU). Optionally pick a name
(I got salty-waters-71436 for my demo app).

4. Easy to set up the tooling. Well, they install the curl | bash way.
Over https. And then the downloaded code downloads some more.

If you want to start small, the setup by hand is easy too, now
download required:

touch ~/.netrc
chmod 600 ~/.netrc
echo "machine login YOUR_EMAIL password
ffffffff-ffff-ffff-ffff-ffffffffffff" >> ~/.netrc

Where the hex string is your API Key (Top-right Person icon > Account
Setings > scroll down)

Now let's write a trivial web app.

1. Make a git repo.
2. Make a two-line Sinatra app.

require "sinatra"
get "/" { "Hello, world!" }

3. Add a two-line Gemfile declaration; add also Gemfile.lock to Git.

source "";
gem "sinatra", "~> 1.4.0"

4. Add a oneliner Procfile.

web: bundle exec ./timeserver

(This was new to me. It's not needed locally but needed for Heroku,
and anyway useful once you outgrow oneliners. Use foreman start to use

5. Use your app name as the remote repo name. Push to deploy (or set up
automatic deployment):

git remote add heroku
git push heroku

That's it! See the app in action:

To see my actual app, instead of the trivial demo built for this blog
post, go to

Martin Vidner, YaST Team

Kuracke oddeleni v restauraci je jako fekalni oddeleni v bazenu
< Previous Next >
This Thread
  • No further messages