author avatar

sachin.kabadi

Wed Jan 24 2024

To launch a Rails app on fly.io, you can follow these steps:

1. Make sure you have the flyctl command-line tool installed.

2. Open a terminal and navigate to the root directory of your Rails app.

3. Launch a new fly.io application by running the following command:
flyctl launch

This command will guide you through the process of setting up your fly.io application. You'll be prompted to provide a name for your app and
select the organization you want to associate it with. Refer below.


   Creating app in ~/list
   Scanning source code
   Detected a Rails app
   ? Choose an app name (leave blank to generate one): list
   ? Select Organization: John Smith (personal)
   ? Choose a region for deployment: Ashburn, Virginia (US) (iad)
   Created app list in organization personal
   Admin URL: 
   Hostname: list.fly.dev
   Set secrets on list: RAILS_MASTER_KEY
   ? Would you like to set up a Postgresql database now? Yes
   For pricing information visit: 
   ? Select configuration: Development - Single node, 1x shared CPU, 256MB RAM, 1GB disk
   Creating postgres cluster in organization personal

   . . .

   Postgres cluster list-db is now attached to namelist
   ? Would you like to set up an Upstash Redis database now? Yes
   ? Select an Upstash Redis plan Free: 100 MB Max Data Size

   Your Upstash Redis database namelist-redis is ready.

   . . .

         create  Dockerfile
         create  .dockerignore
         create  bin/docker-entrypoint
         create  config/dockerfile.yml
   Wrote config file fly.toml

   Your Rails app is prepared for deployment.

   Before proceeding, please review the posted Rails FAQ:
   .



4. Once the launch is complete, you can deploy your Rails app to fly.io by running the following command:
flyctl deploy

This command will build a Docker image of your Rails app and deploy it to fly.io. It may take a few minutes to complete the deployment process.

5. After the deployment is finished, you'll see a message indicating that your app has been deployed successfully. It will also display the URL
where your app is accessible.

You can use following cmd to open app.
fly apps open

That's it! Your Rails app is now running on fly.io. You can access it using the provided URL.

6. If you make any changes to your app, you can redeploy it by running following command again.
flyctl deploy