> ## Documentation Index
> Fetch the complete documentation index at: https://blog.clouddley.com/llms.txt
> Use this file to discover all available pages before exploring further.

# How to Deploy a Ruby on Rails App on a DigitalOcean Droplet using Clouddley

> Learn how to deploy a Ruby on Rails App on a DigitalOcean Droplet using Clouddley.

export const date_0 = "Updated on June 16, 2025"

Deploying a [Ruby on Rails](https://rubyonrails.org/) app on a virtual machine can seem tricky, especially if you’re new to deployment. [**Clouddley**](https://clouddley.com/)  simplifies the process by handling deployment and connects smoothly with DigitalOcean for you. This tutorial walks you through deploying your Rails app to a DigitalOcean Droplet with ease.

## Prerequisites

Before we get started, make sure you have the following:

* A [Clouddley account](https://clouddley.com/)
* A [DigitalOcean account](https://www.digitalocean.com/)
* A [GitHub](https://github.com/) or [Bitbucket](https://bitbucket.org/product/) account.
* [`doctl` (DigitalOcean CLI)](https://docs.digitalocean.com/reference/doctl/how-to/install/) installed and configured
* [DigitalOcean API](https://cloud.digitalocean.com/account/api/tokens) token generated
* [Ruby on Rails](https://guides.rubyonrails.org/install_ruby_on_rails.html) installed locally
* [Git installed](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) locally
* Basic familiarity with the Linux command line

## Create a Ruby on Rails Application

Before deploying your application, it’s important to make sure it runs smoothly on your local machine. Here's how to create and test a Ruby on Rails application step by step.

<Steps>
  <Step title="Generate a new Rails application">
    In your terminal, run:

    ```bash theme={null}
    rails new app 
    ```

    This command creates a new Rails project in a folder named `app`, complete with the default directory structure, configuration files, and a basic setup.
  </Step>

  <Step title="Navigate into your application directory">
    ```bash theme={null}
    cd app
    ```

    This is where all your Rails files and configuration live.
  </Step>

  <Step title="Start the Rails Development Server">
    To run the app locally, start the development server:

    ```bash theme={null}
    bin/rails server
    ```

    By default, this launches the server on `http://localhost:3000`.
  </Step>

  <Step title="Open the App on Your Browser">
    Now that the server is running, open your browser and go to: [http://localhost:3000](http://localhost:3000)
    You should see the default Rails welcome page, which means your app is running correctly!
  </Step>
</Steps>

## Containerize Your Rails App

### Create a Dockerfile

To deploy your Rails app on Clouddley, you need to containerize it using Docker. This involves creating a `Dockerfile` named `triggr.dockerfile` that defines how your application will run in a container.
Here’s a simple `triggr.dockerfile` for your Ruby on Rails app:

```dockerfile theme={null}
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

Here’s how to test your container locally:

1. **Build the Docker Image**:
   ```bash theme={null}
   docker build -f triggr.dockerfile -t my-rails-app .
   ```
   This command builds a Docker image named `my-rails-app` using the `triggr.dockerfile`
2. **Run the Docker Container**:
   ```bash theme={null}
    docker run -p 3000:3000 my-rails-app
   ```
   This command runs the container, mapping port 3000 of the container to port 3000 on your local machine. You can now access your Rails app at `http://localhost:3000`.

## Push Your App to GitHub

Once your Rails app is working locally, the next step is to track it with Git and push it to a remote repository like GitHub or BitBucket. This not only helps with version control, but it's also essential for deploying on Clouddley. For this tutorial, we'll be using GitHub.
Let’s walk through the steps:

<Steps>
  <Step title="Create a New Repository on GitHub">
    Go to [GitHub](https://github.com/) and create a new repository. Give it a name and leave the rest of the settings as default (no README, no .gitignore, you already have those locally).
  </Step>

  <Step title="Initialize Git">
    If you haven’t already, initialize a Git repository in your project folder:

    ```bash theme={null}
    git init
    ```
  </Step>

  <Step title="Add and Commit Your Code">
    Add your files and commit:

    ```bash theme={null}
    git add .
    git commit -m "Initial commit"
    ```
  </Step>

  <Step title="Create branch and add Remote Repository">
    Create a branch and link your local repository to the GitHub repository you created:

    ```bash theme={null}
    git branch -M main
    git remote add origin <your-repo-url>
    ```
  </Step>

  <Step title="Push code">
    Finally, push your code to GitHub:

    ```bash theme={null}
    git push -u origin main
    ```
  </Step>
</Steps>

Now your code is pushed to GitHub, it is ready for deployment.

## Launch a DigitalOcean Droplet

We’ll create a Droplet from the command line using the `doctl` CLI.

Before you begin, ensure you have your DigitalOcean API token ready.

* Authenticate with your DigitalOcean account, run the following command in your terminal:

```bash theme={null}
doctl auth init
```

* Enter your <b>API token</b> when prompted. This will allow doctl to interact with your DigitalOcean account.

* Before creating your Droplet, make sure you have your `vpc_uuid` and `SSH key` added to your DigitalOcean account.

<Accordion title="How to find your VPC UUID">
  Open your terminal and run the command:

  ```bash theme={null}
  doctl compute vpc list
  ```

  This will display all your VPCs along with their UUIDs. Choose the one you want to use for your Droplet.
</Accordion>

<Accordion title="How to add your SSH Key to DigitalOcean">
  Open your terminal and run the command:

  ```bash theme={null}
  doctl compute ssh-key list
  ```

  If you do not have a previously created one, follow the steps below.

  <b>Step 1:</b> To generate an SSH key, run the command:

  ```bash theme={null}
  ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
  ```

  Press <b>Enter</b> to accept the default file location and choose a passphrase if you want one.

  <b>Step 2:</b> To add your SSH key to digitalocean, run:

  ```
  doctl compute ssh-key create "my-key-name" --public-key-file ~/.ssh/id_rsa.pub
  ```

  Replace `my-key-name` with a name you’ll recognize.
</Accordion>

* Create a Droplet using the following command:

```bash theme={null}
doctl compute droplet create app-droplet \
  --image ubuntu-24-10-x64 \
  --size s-1vcpu-1gb \
  --ssh-keys your_ssh_key_id \
  --region nyc1 \
  --vpc-uuid your_vpc_uuid
```

<Note>Make sure you replace `your_vpc_uuid` and `your_ssh_key_id` with your actual values. The SSH key added here allows Clouddley to securely connect to your Droplet during deployments. It uses this key to access the VM, run deployment scripts, and manage your app.</Note>

You will see the output below:

<img src="https://mintcdn.com/clouddley/YkMcNqR8t_n43UbS/images/create-droplet.png?fit=max&auto=format&n=YkMcNqR8t_n43UbS&q=85&s=01092030b97aa83f5e926bc1c481eeed" alt="Creating a droplet in DigitalOcean" width="2602" height="172" data-path="images/create-droplet.png" />

You've created a droplet named `app-droplet` with `Ubuntu24.10 x64` image in the `nyc1` region.

* To verify the Droplet was created successfully, you can run:

```bash theme={null}
doctl compute droplet list
```

This will show you all your active Droplets, their names, IPs, and statuses.

<img src="https://mintcdn.com/clouddley/YkMcNqR8t_n43UbS/images/list-droplet.png?fit=max&auto=format&n=YkMcNqR8t_n43UbS&q=85&s=4a05e0eda04914c7cd7fff2c4a58aa99" alt="Listing all droplets in DigitalOcean" width="2575" height="167" data-path="images/list-droplet.png" />

Note its **public IP address** for SSH access.

## Deploy

Now you have your Ruby on Rails app and Droplet ready, it's time to deploy your app.

* Open your browser and log in to your [Clouddley account](https://app.clouddley.com/auth/signin)
* Navigate to **Apps** and click on <b>Deploy App</b>

<Frame caption="Accessing Apps">
  <img src="https://mintcdn.com/clouddley/p_iVNvg5jCvbMG-4/images/Apps-dashboard.png?fit=max&auto=format&n=p_iVNvg5jCvbMG-4&q=85&s=a351a8b6a71fd42b76757eb1d5b03269" width="3772" height="1705" data-path="images/Apps-dashboard.png" />
</Frame>

<br />

<b>Step 1: Configure Service</b>

* Choose your Git hosting service; either <b>GitHub or Bitbucket</b>. For this tutorial, we will be using GitHub.
* Click on <b>Continue with GitHub</b>

<Frame caption="Choose your Git hosting service">
  <img src="https://mintcdn.com/clouddley/p_iVNvg5jCvbMG-4/images/Apps-configure-service.png?fit=max&auto=format&n=p_iVNvg5jCvbMG-4&q=85&s=2875d8a62a7761282438986e2f4b74b6" width="3820" height="1707" data-path="images/Apps-configure-service.png" />
</Frame>

<br />

<b>Step 2: Configure Git</b>

* To connect your GitHub user or organization account, click the <b>Select username/organization</b> dropdown and <b>Add GitHub account</b>.
* Select your <b>repository</b> and the <b>branch</b> from the dropdown list or quickly search.
* Click on <b>Next</b>

<Frame caption="Setup the Ruby on Rails application repository on Clouddley">
  <img src="https://mintcdn.com/clouddley/p_iVNvg5jCvbMG-4/images/Apps-configure-git.png?fit=max&auto=format&n=p_iVNvg5jCvbMG-4&q=85&s=39ccbf1aad9cddc8d4de699480f9f752" width="3807" height="1715" data-path="images/Apps-configure-git.png" />
</Frame>

<br />

<b>Step 3: Configure your Virtual Machine</b>

* From the **Choose or add server** dropdown, select your VM if it appears in the list. If not, click **+ Add Virtual Machine**.

* To add your VM, enter your droplet's <b>IP address</b> as <b>VM host</b>,  <b>VM user</b>, and the <b>VM port</b> for SSH access.

* Once you've entered the details, verify the connection using the **Clouddley CLI(recommended)** or **SSH**.

<Accordion title="How to Install Clouddley CLI to Verify your DigitalOcean Droplet">
  - Open your local machine’s command line, then connect to the remote VM you want to configure with Clouddley. Use this command to SSH into your DigitalOcean Droplet:

  ```bash theme={null}
  ssh root@<your-droplet-ip>
  ```

  * Install Clouddley CLI by running the command:

  ```bash theme={null}
  curl -L https://raw.githubusercontent.com/clouddley/cli/main/install.sh | sh
  ```

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

  ```bash theme={null}
  clouddley add key
  ```

  Using the CLI, you can deploy resources, manage configurations, and automate tasks efficiently.
</Accordion>

* Click on <b>Verify</b>. This verifies the connection.
* Click on <b>Next</b>

<Frame caption="Configure virtual machine on Clouddley">
  <img src="https://mintcdn.com/clouddley/p_iVNvg5jCvbMG-4/images/Apps-configure-VM.png?fit=max&auto=format&n=p_iVNvg5jCvbMG-4&q=85&s=833ea7178fc7b09e20cbfcad85f46771" width="3817" height="1705" data-path="images/Apps-configure-VM.png" />
</Frame>

<br />

<b>Step 4: Configure app settings</b>

* Insert the <b>name</b> of the application and its <b>port</b>.
* Click on **Next.**

<Frame caption="Configure the App name and port">
  <img src="https://mintcdn.com/clouddley/p_iVNvg5jCvbMG-4/images/Apps-ruby-name.png?fit=max&auto=format&n=p_iVNvg5jCvbMG-4&q=85&s=8a7875ee0cef48de7cc3c985996b84dc" width="3812" height="1702" data-path="images/Apps-ruby-name.png" />
</Frame>

<br />

<Tip>The firewall of the virtual machine should allow access to the application port.</Tip>

<b>Step 5: Configure Environment Variables </b>

* To add environment variables, click on <Icon icon="plus" iconType="solid" /> <b>Add Variable</b>
* Choose an ENV mode: either a <b>single variable</b> or <b>import variables</b>. Learn more [here](https://docs.clouddley.com/apps/extras/environment-variables).

<Tabs>
  <Tab title="Single Variable">
    <img src="https://mintcdn.com/clouddley/p_iVNvg5jCvbMG-4/images/TA-singleVar.png?fit=max&auto=format&n=p_iVNvg5jCvbMG-4&q=85&s=a72c90362f7aa5c82cc72a30d719b30e" alt="Single Variable ENV mode" width="1210" height="945" data-path="images/TA-singleVar.png" />
  </Tab>

  <Tab title="Import Variables">
    <img src="https://mintcdn.com/clouddley/p_iVNvg5jCvbMG-4/images/TA-importVar.png?fit=max&auto=format&n=p_iVNvg5jCvbMG-4&q=85&s=912fde4f5978f8b78b78248d71ad92ad" alt="Import Variables ENV mode" width="1227" height="990" data-path="images/TA-importVar.png" />
  </Tab>
</Tabs>

* Add the key-value pairs and click on <b>Save</b>
* Click on <b>Next</b>

<Frame caption="Adding environment variables">
  <img src="https://mintcdn.com/clouddley/p_iVNvg5jCvbMG-4/images/Apps-ruby-env.png?fit=max&auto=format&n=p_iVNvg5jCvbMG-4&q=85&s=b77f66bd9f9c0328859f475ec26f45e4" width="3820" height="1707" data-path="images/Apps-ruby-env.png" />
</Frame>

<br />

<b>Step 6: Setup Notifications (optional)</b>

* To configure the notifications settings of the application, click on <Icon icon="plus" iconType="solid" /> <b>Add Alert</b>
* Select the <b>Alert type</b>. 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 <b>Email address</b> where you want to receive alerts. (You can add multiple email addresses)
* Click on <b>Save</b>
* Click on <b>Deploy</b>

<Frame caption="Notifications set up and creation of Ruby on Rails application on Clouddley">
  <img src="https://mintcdn.com/clouddley/p_iVNvg5jCvbMG-4/images/Apps-notif.gif?s=79c66a68ffd5284ae5900f7a28855366" width="600" height="267" data-path="images/Apps-notif.gif" />
</Frame>

<br />

<b>Step 7: Test and Verify the app</b>

* Click on <b>Go to Dashboard</b>. Your app will be visible on the apps dashboard.
* After the app deployment is complete, the app status changes from `Deploying` to `Online`

<Frame caption="Ruby on Rails application dashboard overview">
  <img src="https://mintcdn.com/clouddley/p_iVNvg5jCvbMG-4/images/Apps-ruby-dashboard.png?fit=max&auto=format&n=p_iVNvg5jCvbMG-4&q=85&s=da12db07d8722743ca2179b7fb094c48" width="3770" height="1707" data-path="images/Apps-ruby-dashboard.png" />
</Frame>

<br />

* Click on 🌐 Website at the top right corner of the page, this opens the URL of the deployed application in your browser.
* You can test the application's functionalities.

<Frame caption="Ruby on Rails application running from Clouddley on a DigitalOcean Droplet">
  <img src="https://mintcdn.com/clouddley/YkMcNqR8t_n43UbS/images/ruby-app.png?fit=max&auto=format&n=YkMcNqR8t_n43UbS&q=85&s=9b059ba975c933a45b4e0de7d27624dc" width="3812" height="1707" data-path="images/ruby-app.png" />
</Frame>

<br />

## Post-Deployment: Managing Your Ruby on Rails App

Once your Ruby on Rails app is up and running on a DigitalOcean Droplet using Clouddley, management is simple.\
The apps dashboard lets you handle key tasks without touching the server. You can adjust the settings, [scale](https://docs.clouddley.com/apps/extras/scale-applications-on-clouddley) your app, [roll back](https://docs.clouddley.com/apps/extras/how-to-rollback-an-application) to earlier versions, [pause or resume](https://docs.clouddley.com/apps/extras/how-to-pause-and-resume-applications) the app, or remove the app if needed. You’ll also find helpful features to view your deployment history, check logs, manage [environment variables](https://docs.clouddley.com/apps/extras/environment-variables), and connect a [custom domain](https://docs.clouddley.com/apps/extras/custom-domain), all in one place.

<AccordionGroup>
  <Accordion title="Ruby on Rails App Best Practices">
    Want to keep your Rails app clean, fast, and easy to maintain? Here are a few tried-and-true best practices to follow:

    <Icon icon="check" iconType="solid" /> <b>Follow Rails conventions</b>\
    Stick to the framework’s naming and folder structure—it makes your code easier to understand and maintain.

    <Icon icon="check" iconType="solid" /> <b>Keep things modular</b>\
    Use services or concerns to break out logic and avoid bloated models or controllers.

    <Icon icon="check" iconType="solid" /> <b>Secure your config</b>\
    Store sensitive data like API keys and secrets in environment variables or use Rails credentials.

    <Icon icon="check" iconType="solid" /> <b>Write clear commit messages</b>\
    Good commit messages help track changes and make debugging easier down the road.

    <Icon icon="check" iconType="solid" /> <b>Test your code</b>\
    Add basic tests with RSpec or Minitest to catch bugs early and make updates with confidence.

    <Icon icon="check" iconType="solid" /> <b>Watch performance</b>\
    Use eager loading, caching, and proper indexing to keep your app running smoothly in production.

    <Icon icon="check" iconType="solid" /> <b>Stay current</b>\
    Keep Rails and your gems up to date to benefit from security patches and performance improvements.
  </Accordion>
</AccordionGroup>

## Conclusion

That’s it! You’ve now seen how easy it is to deploy your Ruby application on a DigitalOcean droplet using Clouddley. We built Clouddley to make deployments on your favorite cloud platform simpler so you can focus on building great products.

If you’ve got feedback or ideas to make Clouddley even better, let us know [here](https://clouddley.productlane.com/roadmap). We’re excited to see the cool things you’ll deploy with it!

<Card title="Getting started with Clouddley?" icon="user-plus" cta="Sign up today and enjoy a 30-day free trial — no credit card required" href="https://app.clouddley.com/auth/signup" horizontal>
  A backend infrastructure for your own compute. Run apps, databases, brokers, and AI workloads on your VMs, bare metal, or VPS.
</Card>

## Additional Resources

Here are some helpful links to keep learning and refining your deployment setup:

* [Clouddley Documentation](https://docs.clouddley.com/)
* [Run Dockerfile on Clouddley](https://docs.clouddley.com/apps/extras/deploy-an-application-with-a-dockerfile-on-clouddley)
* [DigitalOcean Droplet Docs](https://docs.digitalocean.com/products/droplets/)
* [Ruby on Rails Guides](https://guides.rubyonrails.org/)
* [GitHub Docs](https://docs.github.com/en)

<div className="flex items-center gap-2.5 mb-6 py-0 my-0">
  <img src="https://res.cloudinary.com/dkbbdg1ko/image/upload/faith-kovi-headshot_hbezxg" alt="Faith Kovi" className="w-12 h-12 rounded-full" />

  <div>
    <div className="flex items-center gap-3">
      <p className="text-sm text-gray-600 dark:text-gray-300 flex items-center gap-1 py-0 my-0">
        <span>By</span>

        <a href="https://x.com/Vera__Kaka" target="_blank" rel="noopener noreferrer" className="font-semibold">
          <span>Faith Kovi</span>
        </a>
      </p>

      <button
        onClick={async () => {
      if (navigator.share) {
        try {
          await navigator.share({
            title: document.title,
            text: "Check this out!",
            url: window.location.href,
          });
        } catch (error) {
          console.error("Error sharing:", error);
        }
      } else {
        alert("Sharing not supported on this device/browser.");
      }
    }}
        className="ml-1 hover:scale-110 transition-transform duration-200 ease-in-out"
      >
        <Icon icon="share-nodes" iconType="light" color="#D1D5DB" size="20" />
      </button>

      <button
        onClick={() => {
      navigator.clipboard.writeText(window.location.href);
      alert("Link copied!");
    }}
        className="ml-1 hover:scale-110 transition-transform duration-200 ease-in-out"
      >
        <Tooltip tip="Copied!">
          <Icon icon="clone" iconType="light" color="#D1D5DB" size="18" />
        </Tooltip>
      </button>
    </div>

    <p className="text-xs text-gray-500 py-1 my-0">
      {date_0}
    </p>
  </div>
</div>
