Put your app online with Fly.io
In this guide you’ll deploy your app with Fly.io to make it available to everyone online. After this guide you can share the link with your friends and family to show what you have created during this workshop.
Deploying a single small app with Fly.io is free, with some limitations.
Talk about the benefits of deploying to Fly.io versus traditional servers.
Change the production database
Locally your app uses SQLite as the database to store your ideas. It’s easier to use another database on Fly.io deploys. To deploy with Fly.io we’ll change the database in production to use PostgreSQL.
Install the pg gem
Gemfile file in your Text Editor and change the following line:
into these lines:
Next, run the command below to setup the new database gem:
Update the database configuration
Up next, you’ll need to change the database configuration for the production environment.
Explain what the different Rails environments are. What is “production”?
config/database.yml file in your Text Editor. Change the following lines in the file:
to these lines:
Save the changes in Git by creating a new commit. We’ll need to update our app in Git to deploy these changes.
Create a Fly.io account
Visit the Fly.io sign up page and fill in the form to make a new user account.
On the next screen, click the “Try Fly.io for free” link. You do not need to enter your Credit Card to use Fly.io for free.
Install the Fly.io CLI
To deploy apps with Fly.io, you’ll need to use the Fly.io CLI: a tool for the Terminal app.
Follow the installation instructions on this Fly.io docs page. Continue with this guide when the Fly.io CLI has been installed.
Login to the Fly.io CLI
Run the following command to connect your Fly.io user account to your laptop and deploy your app with Fly.io in the Terminal app.
It will open your Browser with a new tab/window. Either login to your Fly.io user account you created earlier, or click the button starting with “Continue as …”. You are now logged into Fly.io with the CLI.
Configure the app
Run the following command create the necessary configuration in your app to deploy it.
When prompted for questions, enter or select the following:
- Choose an app name:
- Enter: railsgirls-yourname
- Change “yourname” to your (nick)name.
- Choose a region for deployment:
- Choose the region closest to you with the arrow keys and then press Enter.
- Would you like to set up a Postgresql database now?
- Press y and then press Enter.
- Select configuration:
- Choose “Development” from the list.
- Would you like to set up an Upstash Redis database now?:
- Press n and then press Enter.
Your app is now configured to deploy with Fly.io. You’ll need to commit these changes before you can deploy. Commit your changes with this command:
Deploy the app in the future
If you made any new changes to your app and want to deploy the changes in the future, run the following command:
You’ll see a lot of text being printed about the results of the steps needed to deploy the app. Wait until it’s done. It should say “v0 deployed successfully”.
View your deployed app
Your app should now be deployed. This means it’s online for people to see. To know where you can view it, run the following command to open it in your Browser:
You now have your first app deploy! Congratulations! Share the link you see in your Browser’s address bar!
You do not need to deploy your app on another services. Continue with the next numbered guide in the list below.
If you’re ever stuck during a guide, please ask your coach for help and also consult this handy cheatsheet for Ruby, Rails, the console, the Text Editor etc.
- Guide 1: Start of the guide
- Guide 2: Get to know the tools
- Guide 3: Guide to install Rails
- Guide 4: Build Your First App
- Guide 5: Style your app using HTML and CSS
- Guide 6: Add a new page to your app
- Guide 7: Add a new homepage to your app
- Guide 8: Add picture uploads
- Guide 9: Push Your App to GitHub
- Guide 10: Put your app online with one of these services:
- Guide 11: Style the idea pages using HTML and CSS
- Guide 12: Add comments to your app
- Guide 13: Create picture thumbnails
- Guide 14: Test your app with RSpec
View all guides