Below you’ll find a step-by-step process on how to create a brand new Rails app and deploy it to Fly.io. This guide if for you, if you’re looking for to spin up an app because:
- You want to learn how to deploy an application from scratch.
- You’re building your portfolio or a small app.
- You’re looking for a decently abstracted solution.
- You’ve spent hours non-stop battling with documentation or trying to setup things by yourself.
Check the section at the end for more information about why Fly is the recommended option.
Pre-work
- Create a fly.io account (no credit card needed)
- Install flyctl and rv dependencies by running the following commands in your terminal:
curl -Lhttps://fly.io/install.sh| shcurl -LsSfhttps://rv.dev/install| sh
- Restart your terminal and authenticate by running
fly auth login. Your default browser will open and ask you to login, after that you’ll see the following message:
- Close window and go back to your terminal.
Create a Rails app from scratch
-
Run the following command to create a new app (rv will automatically install ruby and rails gem for you):
rvx rails new demo-app -
After the command finish setting up the app, go to the newly created app folder:
cd demo-app -
Install the project dependencies by running:
rv ci
Update Dockerfile
-
The Dockerfile provided by default needs some adjustments to work with Fly, run the following 2 commands to update it:
bundle add dockerfile-rails --optimistic --group developmentrv run rails generate dockerfile --force
Launch!
-
Run the flyctl command to create a new app and deploy your code:
fly launch -
Process will stop and show the default settings:
We're about to launch your Rails app on Fly.io. Here's what you're getting:
Organization: Javier Cervantes (fly launch defaults to the personal org)
Name: demo-app-lingering-cloud-1789 (generated)
Region: San Jose, California (US) (this is the fastest region for you)
App Machines: shared-cpu-1x, 1GB RAM (most apps need about 1GB of RAM)
Postgres: <none> (not requested)
Redis: <none> (not requested)
Tigris: <none> (not requested)
════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════
? Do you want to tweak these settings before proceeding?
-
Type N and return to use the default values.
-
Once the deployment is finish you’ll see URL where the app was created and deployed to a unique URL, for example:
Visit: https://demo-app-lingering-cloud-1789.fly.dev/
Verify
-
You can go to
[URL]/upand you’ll see a green screen that confirms that the deployment was successful. -
Go to your Fly Dashboard, you’ll see that a new machine has been provisioned. A volume is also automatically created to you can use a SQLite database by default:
Deploy with a simple database
-
Run this command to create a products table and the related scaffolded files:
bin/rails generate scaffold Product name:string -
Since the app already created, use the deploy command to push the changes:
fly deploy -
Now you can test the changes in
[URL]/products
That’s it! You can use the same process to deploy an existing application or follow the Getting Started with Rails tutorial for a walk through of how to build a simple e-commerce app.
Why choose PAAS and Fly?
I recommend using a PAAS provider if you’re looking to get something working quickly or if you’re not well versed in “Devops stuff”. For example, self-hosting in a VPS adds additional complexity like provisioning a server, setting up a domain, ssh configuration and you need to take care of security and updates.
More specifically, I selected Fly.io for this guide because it has a free trial that allows you to spin something up, and decide if you want to continue or look for something else. If you only need to deploy a simple application, the price is also very competitive:
Finally, it also has the following benefits:
- No additional Postgres database required (unless you want to).
- Pay as go you plans (you can suspend/stop the machines and you won’t be charged)
- You can use the same Dockerfile to switch to a different provider or self-host later.
- Comprehensive Rails documentation and a community forum for troubleshooting.
You can review and compare with other similar options:
Before you go
Thanks for reaching this far! If you find this guide helpful, please share it with others.
I would love to know if you’re able to deploy your apps or if you have any issues, please send your feedback.
Happy coding!




