Ruby

The following are examples of how to set up a Ruby on Rails application and a Ruby on Rails application with a Dockerfile to deploy on Kinsta’s Application Hosting services from a GitHub repository.

Prerequisites

  • Kinsta’s quick start templates are stored and managed in GitHub; therefore, you need a GitHub account to access them.
  • You need to create a MyKinsta account to deploy the application.

Ruby on Rails

  1. Log in to GitHub and create a new repository from this template (Use this template > Create a new repository): Kinsta – Ruby on Rails Starter.
  2. In MyKinsta, click Applications > Add application > select GitHub, click Connect git provider > Authorize, and log in to your GitHub account.
  3. Choose the Ruby on Rails Starter repository and a Data center location. Leave all other settings as default and click Continue on each step.
  4. On the Summary step, click Deploy now.

During deployment, Kinsta automatically detects the Start command for the web process from the Procfile in the repository and installs dependencies defined in your gemfile file. The app is available as soon as the deployment finishes, and the Kinsta Welcome page loads at your application’s URL.

Kinsta Welcome page after successful deployment of Ruby on Rails.
Kinsta Welcome page after successful deployment of Ruby on Rails.

Prefer to watch the video version?

Web Server Setup

Start Command

When you deploy an application and include a Procfile in the repository, Kinsta automatically creates a web process based on the Procfile in the root of the repository. Use this command in your Procfile to run your web server:

web: rails server

Ruby on Rails With a Dockerfile

  1. Log in to GitHub and create a new repository from this template (Use this template > Create a new repository): Kinsta – Hello World – Dockerfile – Rails.
  2. In MyKinsta, click Applications > Add application > select GitHub, click Connect git provider > Authorize, and log in to your GitHub account.
  3. Choose the Hello World Dockerfile Rails repository and a Data center location, leave all other settings as default, and click Continue.
  4. On the Build environment step, select Use Dockerfile to set up a container image and click Continue > all other settings can remain as default, click Continue > Deploy now.

The Dockerfile must contain the Start command either in a CMD line or ENTRYPOINT instruction. The app is available as soon as the deployment finishes, and the default Rails page confirming successful installation loads at your application’s URL.

Successful installation of Ruby on Rails.
Successful installation of Ruby on Rails.

Deployment Lifecycle

When you first create the app, Kinsta creates a process from the ENTRYPOINT instruction in the Dockerfile:

ENTRYPOINT ["entrypoint.sh"]

If you change this command in the repository after deploying the application, the process is not automatically updated in MyKinsta, so you must also edit the Start command in your application’s Processes.

Jekyll

This is an example of how to set up a static site with Jekyll on Kinsta’s Application Hosting services from a GitHub repository. A workaround using GitHub actions to deploy Jekyll on Static Site Hosting is also available.

Jekyll is an open-source static site generator that uses dynamic React components to produce a customized static site without the need for a database. More information is available on the Jekyll website.

  1. Log in to GitHub and create a new repository from this template (Use this template > Create a new repository): Kinsta – Hello World – Static Site With Jekyll.
  2. In MyKinsta, click Applications > Add application > select GitHub, click Connect git provider > Authorize, and log in to your GitHub account.
  3. Choose the Hello World Jekyll repository and a Data center location. Leave all other settings as default and click Continue on each step.
  4. On the Summary step, click Deploy now.

During deployment, Kinsta automatically detects the Start command for the web process from the Procfile in the repository and installs dependencies defined in your gemfile file. The app is available as soon as the deployment finishes, and the Kinsta Welcome page loads at your application’s URL.

Kinsta Welcome page after successful installation of Jekyll.
Kinsta Welcome page after successful installation of Jekyll.

Web Server Setup

Port

Kinsta automatically sets the PORT environment variable. You should not define it yourself or hard-code it into the application.

Start Command

When you deploy an application and include a Procfile in the repository, Kinsta automatically creates a web process based on the Procfile in the root of the repository. Use this command in your Procfile to run your web server:

web: bundle exec jekyll build && ruby -run -e httpd _site

Deployment Lifecycle

Whenever a deployment is initiated (through creating an application or re-deploying due to an incoming commit), the bundle install command is run.

Was this article helpful?