Some alternatives to heroku
For many years I was a big fan of Heroku. I liked its simplicity to deploy some “exercises” and platforms in “test” mode, there was even a time when I worked with two applications whose production environment was Heroku, and everything works amazingly.
React / Node / Pg
I was recently working with a team of developers on a React application with Node in backend and postgres as a database and we didn’t know where to upload the progress for a presentation to stakeholders. Obviously everything for free and through deploy processes (not pulling in the various environments 💩).
In the search for this solution we went through several options, some that allowed us to upload “everything” to one place (even using docker), but, having time available and with the aim of learning, I tried to leave each “piece” of the application in a different environment/place.
I will explain step by step the different processes and make a mini-review of any platform, but in a few words:
- Database (pg) to Railway. This was just to use Railway which I really liked. The database could have lived without problems next to the back :)
- Backend (node) to Fly.io
- Frontend (react) to Vercel
Railway (database)
Platform to deploy various technologies (almost all thanks to Docker). It allows you to link a repo directly from github, which greatly facilitates the deploy process since it is associated with a branch of the repository.
It can be used for web applications and for databases (the use I gave it). Two things that make Railway great is that you can use it without even registering and that it gives you 5 dollars a month (500 hours).
How to use it? What I do?
Simple, we authenticate ourselves and go to thedashboard. There we press on New Project
Here we choose, among the many options, what we want to do. In my specific case, I used it to create a postgres database. We wait very little time and we will see something like this on the dashboard.
If we click on the project, we will see all the options associated with data manipulation in the database, such as creating tables and data.
To access, in the Connect tab we can access the connection data from desktop clients and from our backend.
Finally, in the Settings tab, there is the Danger section to delete our database or reset the access information.
Fly.io (backend)
It is a platform that allows deploying, but from our local projects. It has a terminal client that we can install and thus, without the need to link repositories or anything, directly from our terminal we can “launch” a deploy. It is compatible with Rails, Rust, Go, Django, Docker and several other technologies.
How to use it? What I do?
Fly.io is used from a client with which we control the deploys and access to the various instances or machines that we will create within our account.
In the home of their website they have the steps to follow.
But, strictly speaking, some steps are missing. A very important one is to authenticate, so the steps to deploy an existing project would be:
# install
brew install flyctl
# login
flyctl auth login
# create config file to make deploys
flyctl launch --image flyio/hellofly:latest
This last step will ask you for some information, including the name of the project. After finishing this configuration, a fly.toml file and a Dockerfile will appear in your project. These files contain the necessary information to perform the correct deployment.
# deploy
fly deploy
When the deploy process is finished, we need to set the environment variable so that our backend (now in fly.io) connects to our database in railway. For that we execute the following command indicating the connection url.
flyctl secrets set DATABASE_URL=$url_de_coneccion
In the online dashboard we can see the domain (hostname) assigned to our deploy application, with this we can connect the frontend to the backend.
Finally, if we want to execute commands such as migrations and things like that, that require the interaction of our backend with the database, we can access the machine (it will be a linux machine) and execute the commands there. For this:
flyctl ssh
There are many more commands and options that fly.io provides through its client (see list of applications, delete applications, list of variables, etc.), we can see the complete list with:
flyctl help commands
Finally, I would like to comment that one of the great things about Fly.io is that I don’t need to associate a repository or a particular state to do a deploy, I simply execute a command and this “uploads” the current state of my project to the server.
Vercel (frontend)
Vercel is a platform that supports a wide variety of web development technologies and tools. It can be used to display web applications and static sites made with programming languages such as JavaScript, TypeScript, HTML, and CSS. It is also compatible with popular frameworks and libraries such as React, Vue.js, Angular, Next.js, and Gatsby. Also, Vercel supports different version control systems, such as Git and Mercurial. In short, Vercel is a flexible platform that allows you to deploy and manage web projects of different types and sizes.
How to use it? What I do?
This part was very simple, because I chose to link a process from github, so the only thing I had to do was give access to the repository and indicate which branch was the one that would “watch” to do deploy. In my case I chose main, so every time I changed something in that branch a new deploy was automatically executed.
The basics to check are:
- General: name of the project and option to delete it.
- Domains: gives you the “public domain” to access the application.
- Git: indicates the repo and branch associated with Vercel’s automatic deploy.
- Environment Variables: here we add the backend url as a variable (obviously our frontend project reads it to access the backend endpoints).
and that is! the whole app “on top”, using different platforms for deployment :) Of course everything could have been deployed on just one, but the idea was to try several alternatives to have more options in the future when you need to deploy on one (free) platform.
In conclusion, I can say each platform is a world and I only saw a part of them. I recommend the 3, they are simple to use (although they have different approaches) and they are highly useful, because they are built to make our lives as developers easier and they clearly do (my fav was vercel).