2- Fly.io Configuration

In this section we will make the corresponding configurations and settings for fly.ioOnce we have correctly configured the project we can upload it to fly.io to start configuring it in the cloud and make the corresponding connections.

Download Fly.io Cli 📥

On the Fly.io Docs website we can find documentation about fly.io and how to configure it, we will also explain how to install the fly.io client correctly in order to upload the project from windows.

As a first step we will open powershell and place:

iwr https://fly.io/install.ps1 -useb | iex

Once placed it will begin to install the fly.io client to be able to connect. If it is installed correctly, you will see the following message:

flyctl was installed successfully to C:\...

It was installed correctly so if we had vsc open or our editor of preference I recommend to close it and reopen it so that the change of the installation is made in this environment correctly.

Configure fly.io 🔧

Once we have downloaded the client we will proceed to configure it in order to upload the project (taking into account that you have already created the account).

We go to the terminal and type:

fly launch

It will ask us to enter an app name > I leave it to your choice but keep in mind that it can only contain numbers, lowercase letters and dashes.

If you have more than 1 organization it will ask you to choose 1 of them.

Depending on the region you may require a paid plan...

Some regions require a paid plan
? Choose a region for deployment:  [Use arrows to move, type to filter]
  Paris, France (cdg)
  Denver, Colorado (US) (den)
  Dallas, Texas (US) (dfw)   
  Secaucus, NJ (US) (ewr) 
  Ezeiza, Argentina (eze)     
  Guadalajara, Mexico (gdl)   
  Rio de Janeiro, Brazil (gig)
> Ezeiza, Argentina (eze)
  Hong Kong, Hong Kong (hkg)  
  Ashburn, Virginia (US) (iad)
  Johannesburg, South Africa (jnb)
  Los Angeles, California (US) (lax)
  London, United Kingdom (lhr)
  Madrid, Spain (mad)
  Miami, Florida (US) (mia)

In my case I selected Argentina as it is the closest to my location.

Postgresql database in our case No as we will use the supabase one.

Upstash Redis database > YES because we need it to configure the message queues.

We select the free part that offers us that is of 100 mb, enough to make tests:

After this we put the name of our redis connection, in my case I decided to put queuebullmq (This function is disabled by default due to configuration problems, if you decide to use it, keep in mind that you can have failures).

Once we have all these steps configured we can deploy with:

Environment variables (.env)

After we deploy the application correctly we can add the environment variables inside fly.io like this in our code editor:

In the [key app name] replace it with the name of your application that you set when you configured it when launching (without the square brackets).

Then as for redis we must configure it, and to connect it we must access to the information of redis from fly.io

Select queuebullmq and then go to usage > Login to your redis instance > Copy the password and the endpoint.

We place the password and host of hostredis in the environment variables replacing [password redis] and [host redis key] (without the square brackets).

Create the Access Token for Meta The Access Token is generated randomly so that Meta can check the correct connection with the bot.

You can place it randomly and it can contain numbers, uppercase and lowercase letters.

It is very important that you save this [access token] because later we will need it again to indicate it to meta (without the square brackets).

Configure PHONE ID

The phone ID is obtained from the meta developer account that we created to use the application and we must obtain this number to place the ID number in the environment variables.

We replace the [phone id key] with the number we got from the phone number id (without the square brackets).

That's all for the general Fly.io configuration, more environment variables will be configured later.

📌 More information about Fly.io's environment variablesarrow-up-right

Última actualización