⬆️ Deploying the bot on Railway

⬆️ Deploying the bot on Railway

Concept

In this guide we will abroad how to deploy your bot on Railway App, a paid service for running apps remotely.
The repository created in this guide is available at:
Testbot
itzviniUpdated Jun 5, 2024

Requirements

  • A Github account
  • Git
  • Knowledge on how to commit and push your repository to Github

How to do it

Create a Github repository to host your code

Login into your Github account and Create a new repository.
notion image
Name your repository, set it to private so no one has access to your code and add a .gitignore template to it avoiding to commit undesired files to your repository.
notion image
Now click on Create Repository
notion image
Your repository is now done and ready to be used!

Clonning your repository into your local machine

In your repository click on Code and then copy the link of your repository.
notion image
Press ctrl + r to execute a command, mine is in portuguese but it should be similar for you if you’re using Windows. Type “cmd” and press ok, this will open the Windows command terminal:
notion image
Now type “cd” and the path where you want to clone your repository into, mine will be in a folder called “bots” located in my desktop, for that I will drag the folder into the terminal an that will automatically copy the path of it.
notion image
Press Enter and now you are in the folder.
notion image
Now let’s clone the repository into the folder, for that you will need Git installed.
Type “git clone” and paste the link of your repository, after that press enter.
notion image
You have now your Github repository in your local machine!

Adding code and the necessary files to your Repository

Left click the folder that you clonned into and click on “Open with Code” or any other text editor that you wish to use, after opening it you should see something like this:
notion image
Now let’s add a bot code to it
I’ve added two files to it, a main.py and a run.py file:
notion image
notion image
Now let’s add a requirements file with all of the required libraries to run the bot. I will be using a modified library with the necessary changes to avoid the bot from raising an error on eventual disconections.
notion image
And lastly let’s add a railway.json file needed to deploy your code on Railway.
notion image
After everything is added let’s send this code to Github using the commands:
git add . git commit -m "First Commit" git push
💡
Remember that you need to first setup your github account in your machine
notion image
Now your code is successifuly stored in Github!

Deploying into Railway

Open Railway and click on “Start New Project”
notion image
Select “Deploy with Github Repo” and login with your Github account.
notion image
Now setup your Railway account, if you wish to support me you can use my referral code: Itsvini
After Creating your account click in New Project.
notion image
Select Github again
notion image
Select your repository
notion image
Click in “Add Variables”
notion image
Write the variable name as “NIXPACKS_PYTHON_VERSION” and set the value as “3.11”, after it click on “Add”.
notion image
Now click on Settings
notion image
Click in the filter settings and write “deploy”, after it click on “Add Start Command”
notion image
On it write “python run.py” and then click in the checkmark.
notion image
Finally, click on Deploy.
notion image
After it your bot will begin to build and after a few seconds it will start.
notion image
notion image
Please send any feedbacks or doubts that you have about this guide in the bot-api channel in the Highrise Discord (https://discord.gg/highrise)
The repository created in this guide is available at
Testbot
itzviniUpdated Jun 5, 2024
 
 
notion image
Built with Potion.so