From Heroku to Fly; Two ways to deploy your projects for free
Tags: heroku, api, howto, flyio
Published: 2022-11-27 19:24:19

> Starting November 28, 2022, we plan to stop offering free product plans and plan to start shutting down free dynos and data services.

It is time, Heroku is ending their free product plans as of [tomorrow](https://blog.heroku.com/next-chapter). This meant one thing for me, to migrate my APIs to a free service. On top of that, I wanted that service to offer me easy solutions while migrating and/or updating my apps. 

So while looking for possibilities, I bumped into [Fly](https://fly.io/). Upon looking at their site; I realised that they have a dedicated page for [deploying Heroku apps](https://fly.io/blog/new-turboku/) in their service, which immediately caught my attention.

In this article, I will walk you through two options how you can deploy your apps in Fly.

### 1. Turboku

Turboku is a service created by Fly to deploy Heroku applications. According to Turboku's [page](https://fly.io/launch/heroku), it is 60% faster than Heroku dynos.

<img src='https://dev-to-uploads.s3.amazonaws.com/uploads/articles/feugdr55w6fdu1pwx553.png' />

Migrating my apps to Fly with Turboku was a breeze, it was my first option to go with and I didn't have any issues whatsoever. 

What is required from you is to; connect Fly account to Heroku, make some configurations (e.g. new app's name, region, which app to deploy) and then clicking on launch. After taking these steps, you will see deploy logs on the left side of the screen and then voilà; your app is deployed and published, congratulations! :sparkles: :partying_face:

<img src='https://fly.io/blog/2022-02-08/turboku-logs.jpg' />

Some key topics to note;
- I didn't have any issues with environment variables. They were [transferred directly with Turboku](https://fly.io/blog/new-turboku/#taking-stock) and this was a really nice surprise.
- Because the app is deployed with Turboku through Heroku and not deployed manually, updating the app later on might be tricky because the app gets the [latest state from Heroku](https://community.fly.io/t/how-to-update-app-created-by-turboku/5978). Which brings me to second way of deploying the app; manual deploys.

**More on Turboku can be found in [their blog post](https://fly.io/blog/new-turboku/)**

### 2. Manual deploy

Manual deploy is not as easy as Turboku, but it will help you have more control over you app's state in Fly. 

First thing we need to do is to install [flyctl](https://fly.io/docs/hands-on/install-flyctl/), a command-line utility by Fly. We will use `flyctl` to login, launch and deploy our app to Fly.

Secondly, looking through docs, we need to find how to deploy our app with selected language. For me it was Node.js and looking through their docs, it wasn't difficult to find the [guide](https://fly.io/docs/languages-and-frameworks/node/).

What comes next is following the guide and deploying the app. Congratulations again! :sparkles: :partying_face:

Some key topics to note in here are;
- Setting up secrets/environment variables require to check [another page](https://fly.io/docs/reference/secrets/#setting-secrets) in their documentation but it isn't difficult or too much time consuming to set them. Every time you set a new secret, app will be re-deployed.
- So far I deployed two of my APIs with Fly and both uses MongoDB. I needed to provide production URL for both but here comes the issue; in first one I could deploy the app with only `flyctl launch` and then `flyctl deploy`. But in second one, I needed to provide MongoDB connection string while deploying otherwise deploy failed (environment variables are supported with a [flag](https://fly.io/docs/flyctl/deploy/)).

```
flyctl deploy -e KEY=VALUE
```
This command was enough to overcome my issue and then I could deploy successfully.

I hope this guide was helpful to overcome a bumpy transition to a better one.

Finally, I would like to mention that this how-to guide/post was written purely from my experience. Thanks for making it thus for in my first blog post ever!