Page cover

πŸ“—Deploy a Ruby on Rails App on Clouddley

Learn how to deploy a Ruby on Rails app on Clouddley.

In this guide, you'll learn how to deploy a Ruby on Railsarrow-up-right Application on Clouddley, a backend infrastructure for your compute resources that is an advanced runtime auto-detection platform for zero-downtime deployments across different server types. Let's begin!

Prerequisites

Deploy your Ruby on Rails Application

Create a Dockerfile

Before deploying your Ruby app on Clouddley, create a Dockerfile triggr.dockerfile which defines how the Ruby app should be containerized.

circle-info

Best Practice: When creating a Dockerfile, use a lightweight base image to reduce image size. Always specify exact versions for dependencies to ensure consistency.

triggr.dockerfile
FROM ruby:3.4.4-alpine

# Install only the essentials for your gems
RUN apk add --no-cache \
    build-base \
    yaml-dev \
    nodejs \
    yarn \
    tzdata \
    git

# Set working directory
WORKDIR /app

# Copy Gemfile and Gemfile.lock first (for caching)
COPY Gemfile Gemfile.lock ./

# Install gems
RUN bundle install

# Copy the rest of the application
COPY . .

EXPOSE 3000

CMD ["rails", "server", "-b", "0.0.0.0"]

Building and Running the Container Locally

Before deploying to Apps, verify that the container works locally.

  1. Build the Docker image:

  2. Run the container:

  3. Verify the app is running by visiting http://localhost:3000

Accessing Apps on Clouddley

  • Open your browser and log in to your Clouddley account

  • Navigate to Appsarrow-up-right and click on Deploy App

Image of Triggr Apps dashboard.
Accessing Apps on Clouddley

Step 1: Configure Service

  • Choose your Git hosting service; either GitHub or Bitbucket. For this tutorial, we will be using GitHub.

  • Click on Continue with GitHub

Configuring Git hosting service during app deployment on Apps.
Choose your Git hosting service

Step 2: Configure Git

  • To connect your GitHub user or organization account, click the Select username/organization dropdown and Add GitHub account.

  • Select your repository and the branch from the dropdown list or quickly search.

  • Click on Next

Configuring the Git repository during app deployment on Apps.
Setup the Ruby on Rails application repository on Clouddley

Step 3: Configure your Virtual Machine

In the Choose or add server dropdown, select your virtual machine (VM) if it’s already listed. If not, select + Add Virtual Machine.

Enter the following details to configure your VM:

  • Hostname or IP address

  • Username

  • SSH port

After adding the details, use the Clouddley CLI (recommended) or connect via SSH to verify the connection.

The Clouddley CLI is a command-line tool that allows you to interact with the Clouddley Platform from your terminal.

  • Open the command line of the remote VM you want to configure to Clouddley and install Clouddley CLI by running the command:

  • To add the SSH public key, run the command:

Using the CLI, you can deploy resources, manage configurations, and automate tasks efficiently.

  • Click on Verify. This verifies the connection.

  • Click on Next

Configuring the virtual machine during app deployment on Clouddley
Configuration of virtual machine on Clouddley

Step 4: Configure app settings

  • Insert the name of the application and its port.

  • Click on Next

Configuring App settings (name and port) during app deployment on Clouddley
Configure the App name and port
circle-info

The firewall of the virtual machine should allow access to the application port.

Step 5: Configure Environment Variables

  • To add environment variables, click on βž• Add Variable

  • Choose an ENV mode: either a single variable or import variables. Learn more here.

Image showing the single variable ENV mode on Clouddley
Single variable ENV mode
  • Add the key-value pairs and click on Save

  • Click on Next

Image showing environment variables added during app deployment on Clouddley.
Adding environment variables

Step 6: Set up Notifications (optional)

  • To configure the notification settings of the application, click on βž• Add Alert

  • Select the Alert type. For this tutorial, we will set up Email alerts.

  • Toggle on the buttons of the deployment event (failed, timed out, or success) you want to be notified of.

  • Enter the Email address where you want to receive alerts. (You can add multiple email addresses)

  • Click on Save

  • Click on Deploy

A gif showing how to set up notifications on Clouddley.
Notifications set up and creation of Ruby on Rails application on Clouddley

Step 7: Test and Verify the app

  • Click on Go to Dashboard. Your app will be visible on the apps dashboard.

  • After the app deployment is complete, the app status changes from Deploying to Online

An image of the overview of a successfully deployed Ruby on Rails application on Clouddley.
Ruby on Rails application dashboard overview
  • Click on 🌐 Website at the top right corner of the page, which opens the URL of the deployed application in your browser.

  • You can test the application functionalities.

An image of the Ruby on Rails application running on Clouddley on the web.
Ruby on Rails application running from Clouddley on a cloud virtual machine

You have deployed a Ruby on Rails application successfully on Clouddley. You can manage it directly from the app dashboard by clicking the three dots (...) at the top-right corner to access Edit, Instant Rollback, Scale, Pause, and Delete options.

Additionally, you can switch to different tabs on the application dashboard to perform the following actions: view your deployment history, view or download logs, add a custom domain, and view the environment variables.

Conclusion

You've successfully deployed a Ruby on Rails application on Clouddley! To access the source code of this application, check herearrow-up-right. Furthermore, to explore how different frameworks can be deployed on Clouddley, check out our how-to guides.

Last updated