Fly.io: Just 2 commands and the app is live.
Tags: rails, devops, codenewbie
Published: 2023-07-30 15:54:07

I am a rails developer. I started out my developer life as a rails developer. I mention this because ruby on rails helps you build a lot very fast. If you are looking for the fastest way to move from idea to MVP, rails is almost always one of the top suggestions. When I wanted to pivot to mobile dev, I started with React Native, but I felt a lot more comfortable working with flutter. Then now, I was working on the ruby on rails hackathon this past weekend and one of the goals was to try out [fly.io](https://fly.io) as a hosting provider. And well, fly.io gave me the same level of comfort that rails and flutter do. That comfort I think comes from the adherance, at least somewhat, to the doctrine of convention over configuration. 

Ruby on rails works hard to scaffold a lot for you. Similarly to flutter compared to React Native at least. And now, I find that Fly does the same thing. When I was using heroku and render to host my projects, there is often a lot of jumping between my terminal, and the browser in order to set up a postgres database, a redis server and to actually set up the rails server. Fly.io just gives you the cli tool `flyctl` and gets you up and running in no time flat. Let me explain.

### Authorize the login for `flyctl`
After you download the tool and install it you would need to login using the command `flyctl auth login`. If you have an account, it will open up your browser and log you in, and this is the last time you may need to visit your browser until your deployment is done. (I promise)

### Let's get deploying. 
So now we stay within the terminal. Make sure you're in the working directory of your project. In this case it is a rails project. First command we run is `fly launch`. This command will detect the type of app within the directory, be it rails, Phoenix, Django or Laravel. The following are a list of prompts it will ask you.
1. If a configuration file(fly.toml) is found, it will as if you want to copy the configuration to the new app
2. The name of your app.
3. If the app already exists, it will ask if you want to launch into that app.
4. The region in which you want to deploy your app
5. Whether or not you want to create a postgres database for your app
6. Whether or not you want to create a redis server for your app

And that's about it for that command. Flyctl tool will do the rest.

Once that part is done, the next command we run is `fly deploy`
The `fly deploy` command gets the app name from the fly.toml file. Then flyctl will start the process of deploying your application to the Fly Platform and return you to the command line when it’s done. If this command runs successfully, then the app has been successfully deployed. The last command you can run is `fly open` and this will open your app on your your browser.

So that's it. No really, that's it. 2 commands and your app is up and running. Idk about you, but I think it's pretty  amazing. 

### Conclusion
This is the first time I have used fly.io and I think that the developers over there are putting in a lot of work to help with the developer experience of deploying. The great thing is, a lot of the configuration files are also copied to your local machine allowing you to make changes as you see fit, but if you are looking to get from idea to MVP, I think that using fly.io for hosting is such a win. 

To the team at fly.io, if you're reading this, ABSOLUTELY STUNNING WORK!!!.