{"id":486,"date":"2014-12-21T16:44:34","date_gmt":"2014-12-21T14:44:34","guid":{"rendered":"http:\/\/misto.ch\/?p=486"},"modified":"2014-12-21T16:44:34","modified_gmt":"2014-12-21T14:44:34","slug":"own-paas-with-runabove-and-dokku","status":"publish","type":"post","link":"https:\/\/misto.ch\/de\/2014\/12\/21\/own-paas-with-runabove-and-dokku\/","title":{"rendered":"Run your own PaaS with RunAbove and Dokku"},"content":{"rendered":"<p>Last time, we looked at how we can <a title=\"Play 2.3 Applications on OpenShift\" href=\"http:\/\/misto.ch\/play-on-openshift\/\">run a Play application on Open Shift<\/a>. Open Shift offers small instances (512MB memory) for free, but if you need more memory, it quickly gets rather expensive. For 1GB, the hour costs you 5 cents (that&#8217;s about 36$ per month). That&#8217;s too much for my hobby projects, so I started looking for alternatives. My requirements included 1GB of memory, a relational database that can hold more than just a few megabytes of data and ideally a deployment that isn&#8217;t any more work than a git push.<\/p>\n<p>Unfortunately, I couldn&#8217;t find a PaaS provider that fit my needs, but I remembered reading about <a href=\"http:\/\/progrium.viewdocs.io\/dokku\/index\">Dokku<\/a>, the &#8222;Docker powered mini-Heroku. The smallest PaaS implementation you&#8217;ve ever seen&#8220;. Last week, I also learned about <a href=\"http:\/\/runabove.com\/\">RunAbove<\/a>, and that they not only offer really cheap machines, but also have pre-configured Dokku images (which I later realized isn&#8217;t such a big deal because it&#8217;s really simple to install):<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-490\" src=\"https:\/\/misto.ch\/wp-content\/uploads\/2014\/12\/android-browser1.png\" alt=\"\" width=\"601\" height=\"151\" srcset=\"https:\/\/misto.ch\/wp-content\/uploads\/2014\/12\/android-browser1.png 1070w, https:\/\/misto.ch\/wp-content\/uploads\/2014\/12\/android-browser1-300x75.png 300w, https:\/\/misto.ch\/wp-content\/uploads\/2014\/12\/android-browser1-768x193.png 768w, https:\/\/misto.ch\/wp-content\/uploads\/2014\/12\/android-browser1-1024x257.png 1024w\" sizes=\"auto, (max-width: 601px) 100vw, 601px\" \/><br \/>\n<!--more--><\/p>\n<p>If you search for <a href=\"https:\/\/twitter.com\/search?f=realtime&amp;q=runabove%20code&amp;src=typd\">runabove code<\/a> on Twitter, you&#8217;ll find many discount codes that give you a $10 credit, so you can try this for free. After signing up, add a new instance:<\/p>\n<p><a href=\"https:\/\/misto.ch\/wp-content\/uploads\/2014\/12\/runabove-setup.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-498\" src=\"https:\/\/misto.ch\/wp-content\/uploads\/2014\/12\/runabove-setup.png\" alt=\"runabove-setup\" width=\"600\" height=\"901\" srcset=\"https:\/\/misto.ch\/wp-content\/uploads\/2014\/12\/runabove-setup.png 674w, https:\/\/misto.ch\/wp-content\/uploads\/2014\/12\/runabove-setup-200x300.png 200w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a>The next step will ask you for an image &#8211; choose Ubuntu 14.04 (we&#8217;re not using the predefined Dokku image because its version of Dokku is a bit dated) &#8211; an SSH key, a name, and a few seconds later your machine will be provisioned.<\/p>\n<p><a href=\"https:\/\/misto.ch\/wp-content\/uploads\/2014\/12\/runabove-machines.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-502\" src=\"https:\/\/misto.ch\/wp-content\/uploads\/2014\/12\/runabove-machines-1024x161.png\" alt=\"runabove-machines\" width=\"597\" height=\"94\" srcset=\"https:\/\/misto.ch\/wp-content\/uploads\/2014\/12\/runabove-machines-1024x161.png 1024w, https:\/\/misto.ch\/wp-content\/uploads\/2014\/12\/runabove-machines-300x47.png 300w, https:\/\/misto.ch\/wp-content\/uploads\/2014\/12\/runabove-machines-768x121.png 768w, https:\/\/misto.ch\/wp-content\/uploads\/2014\/12\/runabove-machines.png 1245w\" sizes=\"auto, (max-width: 597px) 100vw, 597px\" \/><\/a>One neat thing our PaaS will be able to do is hosting applications on sub-domains, without having to change any DNS entries. But for this to work, we first need a domain name and a wildcard DNS entry. Don&#8217;t worry if you don&#8217;t have a spare domain name lying around, you can <a href=\"http:\/\/freenom.com\/en\/index.html\" target=\"_blank\">get one for free at Freenom<\/a>. During the registration, you can choose a custom\u00a0 DNS server. For example, <a href=\"https:\/\/zonomi.com\/\" target=\"_blank\">Zonomi<\/a> offers you one DNS zone for free and it allows wildcard DNS entries. Now, the setup of all this seems to resemble the chicken-egg problem: Freenom asks for the DNS server and Zonomi asks for the Domain, but in the end it all works out, just enter the configuration. I went with the domain <a href=\"http:\/\/ownpaas.tk\">ownpaas.tk<\/a> (use the <em>Register a Free Domain Now<\/em> button at the bottom):<\/p>\n<p><a href=\"https:\/\/misto.ch\/wp-content\/uploads\/2014\/12\/freenom-setup.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-504\" src=\"https:\/\/misto.ch\/wp-content\/uploads\/2014\/12\/freenom-setup-611x1024.png\" alt=\"freenom-setup\" width=\"611\" height=\"1024\" \/><\/a><\/p>\n<p>On Zonomi, setup your domain with a wildcard for the subdomains and enter the IP address of your RunAbove instance:<\/p>\n<p><a href=\"https:\/\/misto.ch\/wp-content\/uploads\/2014\/12\/zonomi.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-505\" src=\"https:\/\/misto.ch\/wp-content\/uploads\/2014\/12\/zonomi.png\" alt=\"zonomi\" width=\"600\" height=\"349\" srcset=\"https:\/\/misto.ch\/wp-content\/uploads\/2014\/12\/zonomi.png 977w, https:\/\/misto.ch\/wp-content\/uploads\/2014\/12\/zonomi-300x175.png 300w, https:\/\/misto.ch\/wp-content\/uploads\/2014\/12\/zonomi-768x447.png 768w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a>After a few minutes, you can try to ping your domain and you&#8217;ll see that the address is resolved to the correct instance. The Ping won&#8217;t work though, because the default RunAbove network configuration doesn&#8217;t allow it. But you can ssh into your\u00a0 server now:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n% ssh admin@ownpaas.tk\n<\/pre>\n<p>If you can&#8217;t, you need to inspect your RunAbove network settings. Switch to Expert Mode (in the top right menu), go to Access &amp; Security and edit your default rules. There are pre-defined rules, just add the one for SSH and while you&#8217;re at it also for HTTP.<\/p>\n<p><a href=\"https:\/\/misto.ch\/wp-content\/uploads\/2014\/12\/runabove-security.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-509\" src=\"https:\/\/misto.ch\/wp-content\/uploads\/2014\/12\/runabove-security-1024x548.png\" alt=\"runabove-security\" width=\"601\" height=\"322\" \/><\/a>The next step is to install Dokku. Just follow their instructions on <a href=\"http:\/\/progrium.viewdocs.io\/dokku\/installation\">how to install the latest stable version<\/a>.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n% ssh admin@ownpaas.tk\nadmin@my-own-paas:~$ # follow the instructions\n...\nAlmost done! For next steps on configuration:\n  https:\/\/github.com\/progrium\/dokku#configuring\n<\/pre>\n<p>If you don&#8217;t end up with the above message, just run the command again until you do. I needed three attempts&#8230; Now, we need to update the Buildpacks that Dokku uses. Buildpacks exist for many languages and frameworks and provide the framework specific configuration to Dokku (actually, they come from Heroku, but Dokku uses the same configuration).<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n% ssh admin@ownpaas.tk\nadmin@my-own-paas:~$ git clone https:\/\/github.com\/progrium\/buildstep.git\nadmin@my-own-paas:~$ cd buildstep\nadmin@my-own-paas:~$ sudo make build\n<\/pre>\n<p>Next, update the hostname so that Dokku knows how to deploy your applications to subdomains. Back on your local machine, copy your public key to the server and authorize it to use Dokku.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nadmin@my-own-paas:~$ sudo sh -c &quot;echo ownpaas.tk &gt; \/home\/dokku\/HOSTNAME&quot;\nadmin@my-own-paas:~$ sudo sh -c &quot;echo ownpaas.tk &gt; \/home\/dokku\/VHOST&quot;\nadmin@my-own-paas:~$ logout\nConnection to ownpaas.tk closed.\n% cat  ~\/.ssh\/id_rsa.pub | ssh admin@ownpaas.tk &quot;sudo sshcommand acl-add dokku $USER&quot;\n<\/pre>\n<p>Ok, now let&#8217;s create and deploy a Play application to our PaaS:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n% activator new play-scala play-scala\n% cd play-scala\/\n% git init\n% git add .\n% git commit -a -m &quot;init&quot;\n% git remote add dokku dokku@ownpaas.tk:play-scala\n% git push dokku HEAD\nCounting objects: 30, done.\nDelta compression using up to 4 threads.\nCompressing objects: 100% (25\/25), done.\nWriting objects: 100% (30\/30), 1010.68 KiB | 0 bytes\/s, done.\nTotal 30 (delta 0), reused 0 (delta 0)\n-----&gt; Cleaning up ...\n-----&gt; Building play-scala ...\n-----&gt; Adding BUILD_ENV to build environment...\n-----&gt; Play 2.x - Scala app detected\n-----&gt; Installing OpenJDK 1.6...done\n-----&gt; Downloading SBT...done\n-----&gt; Priming Ivy cache (Scala-2.11, Play-2.3)... done\n-----&gt; Running: sbt update\n...\n-----&gt; Creating non-ssl nginx.conf\n-----&gt; Running nginx-pre-reload\n       Reloading nginx\n=====&gt; Application deployed:\n       http:\/\/play-scala.ownpaas.tk\n<\/pre>\n<p>And that&#8217;s it! The domain name is determined by the name of the remote repository. <a href=\"http:\/\/misto.ch\/add-database-to-your-paas\/\" title=\"Add a Database to your own PaaS\">Next time, we&#8217;ll deploy a slightly more interesting application that uses a database!<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Last time, we looked at how we can run a Play application on Open Shift. Open Shift offers small instances (512MB memory) for free, but if you need more memory, it quickly gets rather expensive. For 1GB, the hour costs you 5 cents (that&#8217;s about 36$ per month). That&#8217;s too much for my hobby projects, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[26,27],"tags":[35,36,38],"class_list":["post-486","post","type-post","status-publish","format-standard","hentry","category-infoq","category-scala","tag-paas","tag-play","tag-scala"],"_links":{"self":[{"href":"https:\/\/misto.ch\/de\/wp-json\/wp\/v2\/posts\/486","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/misto.ch\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/misto.ch\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/misto.ch\/de\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/misto.ch\/de\/wp-json\/wp\/v2\/comments?post=486"}],"version-history":[{"count":0,"href":"https:\/\/misto.ch\/de\/wp-json\/wp\/v2\/posts\/486\/revisions"}],"wp:attachment":[{"href":"https:\/\/misto.ch\/de\/wp-json\/wp\/v2\/media?parent=486"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/misto.ch\/de\/wp-json\/wp\/v2\/categories?post=486"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/misto.ch\/de\/wp-json\/wp\/v2\/tags?post=486"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}