Sinatra is a free and open source Web Application framework written in Ruby language. It is an alternative to other Ruby web application frameworks such as Ruby on Rails, Padrino, Camping and Merb. It’s basically used to develop web applications which are dependent on the Rack web server interface.
I came across multiple queries about Rack based application support on App42 PaaS. Hence, I decided to write a small blog on the deployment of Sinatra Application on App42 PaaS.
Let’s start off by creating app.rb and config.ru files. Copy and paste the code given below respectively.
/APP Root Dir/app.rb
require 'sinatra'
get '/' do
"Welcome to App42 PaaS"
end
/APP Root Dir/config.ru
require './app'
run Sinatra::Application
Now it’s time to create a Gemfile to solve application gem dependencies by using bundle init command:
$ bundle init
Once Gemfile has been created, add sinatra gem to Gemfile. Your Gemfile will look like as shown below:
# A sample Gemfile
source "https://rubygems.org"
gem "sinatra"
Now run bundle update to resolve dependencies.
Test if your sinatra application is working by using the command:
Go ahead and open the link http://localhost:9292/ in any browser. Congratulations, your Sinatra application works fine.
Now let’s deploy your application on App42 PaaS. You first need to setup an environment by providing certain inputs which will be required to deploy and run your App.
As in the above example, we will use ’demo’ as the name of the application which we shall build with the following inputs: Instance Type(shared), IaaS Provider(IaaS Provider on which you want your application to deploy), Runtime, Framework and Web Server. Finally enter the desired Kontena power(Kontena is a virtualized container which runs your apps and services, One Kontena power is equal to 256 MB RAM and 128 MHz CPU). Once you hit enter, it will take few seconds to create a virtual environment for your app.
You are now ready to deploy your application on App42 PaaS platform, which can be done in two ways:
1. By using the GIT URL
2. Creating a binary (including all dependencies) on your local development environment.
Here we are going to deploy your application using Binary source code.
And you’re done! You have successfully deployed your Sinatra App on App42 PaaS Platform. You can now visit your new DEMO app at https://demo.iab.app42paas.com
That’s all for now. You can learn more by visiting App42 PaaS Dev Center. If you have any questions or need any further assistance, please feel free to reach out to us at support@shephertz.com.
Leave A Reply