Deploy Rails 7 with MySQL and Redis on Hetzner Cloud

Cloud 66
4 min readApr 28, 2023

--

We have created a simple Rails 7 application to showcase how easy it is to deploy to Hetzner Cloud with Cloud 66.

Our Rails 7 App

For this article, we are going to use Tickerizer, one of our sample Rails applications. Tickerizer is built with Rails v7.0.2.2, Hotwire (Turbo and Stimulus), TailwindCSS, and ViewComponents in a single stack, with a MYSQL and Redis backend.

Tickerizer allows you to add stock tickers to your dashboard. To use it you need a free Alpha Vantage API key, which you can get it here: https://www.alphavantage.co/support/#api-key

To deploy with Cloud 66 all you need is a git repository and an account with a cloud provider (or your own server). We will use Hetzner Cloud for the deployment destination to show you how easy the process is.

From Git to Hetzner Cloud in Minutes

Sign up for Cloud 66 Account:

You can sign up here and get your first four weeks free, no credit card required. You can sign up using your GitHub or Google account, or use your email and create a password.

Connect your GitHub repo

Next we will ask you for (read-only) access to your code repository, so that we can build and deploy your application for you.

Deploy our Rails 7 sample application:

To use our sample app click on the ‘Enter the repo URL’ link and paste in the Tickerizer repo link: https://github.com/cloud66-samples/tickerizer. Choose the branch, environment, give your app a name and click the ANALYZE button.

Or deploy your own Rails 7 application:

If you signed up with GitHub, select your application repo from your GitHub account, choose the branch, environment, give your app a name and click ANALYZE button, as shown in the animation.

Analyze, add Hetzner Cloud, and Deploy:

Next, we’ll pull the code from the repo to analyze the app and suggest the best configuration. If needed you can commit changes to your repo and then reanalyze your code.

Next, we will ask you to choose a deployment destination. We offer three options:

  • Deploy to a cloud provider, e.g. Hetzner Cloud.
  • Deploy to your own servers, e.g. Hetzner bare metal server. Note : You will have to register the server using our Registered Servers feature.
  • Hybrid — deploy to both cloud and your own servers, e.g. Deploy the frontend to Hetzner Cloud and use Hetzner bare metal for your DB.

We are going to deploy the Tickerizer app on Hetzner Cloud. To connect Cloud 66 with Hetzner Cloud, we’ll ask you to enter your Hetzner API Key. Once the cloud is connected, you can specify the region and the server size for the deployment.

Lastly, you can decide on how to deploy your databases. As this is a demo app we’ll choose the 0ption to deploy the app, our MySQL database, and Redis all to the same shared web server. _ Note _: We do not recommend this option for critical apps or production environments.

All done! Click the START DEPLOYMENT button.

Cloud 66 Dashboard — Manage Your Application:

Once your application is deployed, you can manage it via your Dashboard. On the right-hand side of the overview page, you will find your application menu. Let’s start with the DEPLOY button. There are three deployment options:

  • Deploy Application — this is a standard deployment.
  • Deploy with Options — e.g. serial or parallel deployment with Blue/Green or Canary rollout strategies.
  • Create a New Profile — also known as a Deployment Profile e.g. you may only want to deploy your front-end servers, and leave your databases undisturbed.

Application Overview:

At the top of the page, next to your application name, we give your application a score from ‘A’ to ‘F’. You can click on the icon to see how you can improve your application e.g. by adding a load balancer, failover group or backups, etc.

Below, we list all your application’s servers. You can click on each server to see more detailed information.

Next, we share ‘ProTips’ with you to improve the performance and reliability of your application. They are a handy way to improve your application score.

At the bottom of the page you’ll find ‘Add-Ins’. These let you easily add components and services to your application e.g. GlusterFS, Redis, SSL certificates, Managed Database Backups, etc.

Deployments

Shows a timeline of your deployments with information on who deployed what and when. Additionally, you can track when specific code commits were deployed.

Configuration

Allows you to edit environment variables, Config Store, and Configuration Files including manifest.yml, MySQL and Nginx, ModSecurity, and OWASP.

Network

Allows you to manage your network firewall, traffic filters, web application firewall, OWASP rules, and surge protection. You can also implement redirect rules and Application Private Network (APN) features.

Protects your application and servers against denial of service and brute-force attacks.

Collects and displays real-time logs that can help you find and eliminate bugs and configuration issues in your Rails app.

Setting & Information

This tab allows you to see your application information and to edit your settings e.g. change a deployment strategy. You can also set up your notifications and choose what you would like to be informed about and via which channel.

Clone or Delete

If you no longer need this application, you can click on the Delete button. Or if you need another application with the same structure as one of your existing applications, you can clone it with a click of a button instead of building your app from the scratch. You can change the deployment destination to a different region as needed.

Originally published at https://blog.cloud66.com.

--

--

Cloud 66

DevOps-as-a-Service to help developers build, deploy and maintain apps on any Cloud. Sign-up for a free trial by visting: www.cloud66.com