My interest in blockchain technology led me to set up a blockchain node for the Babylon's project https://babylonchain.io/, which aims to bring proof of stake to Bitcoin (you can find the Docker repo I contributed to here). Given the need for computing power and a fast network to synchronize the blocks, I opted for a Virtual Private Server (VPS), which proved to be an excellent choice. I hesitated briefly when I saw the price, but I felt it was worth the experiment.

Contabo VPS renting for 3 months

Misconceptions Prior Exploration

I must confess, I had many misconceptions about using and managing a server. I've always been a fan of services like Firebase, Supabase, etc., that let you focus on your product rather than on complex infrastructures that might not be necessary. As a macOS user who values simplicity, I had negative experiences setting up Linux Ubuntu (but Manjaro was better) on my old Mac mini to use as a server. I found myself struggling with basic tasks and constantly entering my root password.

Don't feed the troll
Although I can not complain about my rural connection. And this test is Wi-Fi.

However, as technical stacks become increasingly complex (Monorepo/Turborepo with back-end Strapi/Directus, front-end: Next.js or Expo or both, not to mention different environment variables and credentials per customer), I found myself enamored with a service called Railway.

Railway ❤️

Railway is a one-click monolith project deployer that allows the deployment of a wide variety of technical tools and services, such as Ghost blog, Strapi, Directus, n8n, AFFiNE, etc..., using templates built by other developers as a part of a large community. Its configurations are comprehensive but not redundant, making the platform high-quality and user-friendly.

CleanShot 2024-05-20 at 03.07.52@2x.png

The generous $5 monthly credit allocation, actually make it free in most of the cases (just like fly.io), since, contrarily to DigitalOcean, you don’t pay for uptime - only for usage (deploy, customer traffic, data storage). Besides, the project settings allow you to:

  • See a projection of the final cost at the end of the month (generally few cents)
  • Configure multiple environment in the same project!
  • Although you can deploy a Postgres/MySQL service on Railway, you also have the freedom to simply point your service to your database hosted somewhere else.

As my goal was to enhance my infrastructure skills, I spent time experimenting with Docker and Docker Compose. I even tried creating a template. In the end, I realized that this is a method of cost-saving—a brilliant business model 🤯

This explains why templates are so high quality

It Was A Trap

Don’t get me wrong, Railway service is awesome, and I still use it for quick stuffs. But my passion for Railway turned into the crazy idea that it would be nice if Railway would exist in a self-hosted version 🤔

I talked about it to a very close friend, and he put me back on track (thank god):

This is not the way… There are (great) tool designed for managing infrastructure like Terraform or Docker, there is no point in such a service since it’s anyway not the management team which is going to deploy the infra and your product, wake up!

Indeed, I was doing exactly what I dislike in others: seeking a more complex workaround to avoid using the technology itself.

Hello Webflow, Wordpress 💩, and all those no-code tools that finally are often managed (and learnt the hard way) by developers, because the people for whom they selected those no-code solutions are reluctant to spend even 5 minutes learning how to use them 🙄

The Virtual Private Server (VPS)

But wait a second... I have this expensive VPS I paid for, for the next 3 months. Let's see what we can achieve with that...

The VPS offered me enhanced control and performance, and the isolated environment ensured undisturbed performance and security. It also provided me with root access and scalability. Good surprise: I rarely had to enter the root password for an unknown reason. It is BLAZING FAST and the lack of UI never felt like an obstacle, it is awesome! Because I'm not a keyboard and CLI purist, I sometimes use JetBrains IDE built-in feature for remote browsing with SSH to easily edit and upload files:

One of the secret of not missing a UI on your VPS server 🖥️

Given its capabilities, I found that I could host numerous projects running in parallel. I also realized that self-hosting on your VPS, especially with Docker, is quite straightforward!

  • You choose a custom subdomain name on one of your owned domains. On your registrar (I advise you Vercel Domains for simplicity) you create a A record with the subdomain pointing to your VPS IP address.
  • After connecting with SSH to the VPS, you generally have a docker compose file (or try to write yours if you have only a Dockerfile) that allow you to spin up your service on localhost using: docker compose up -d --build
  • Then you simply need to configure Nginx to forward your 80 and 443 ports to the localhost project exposed port in Docker. I used to do it manually, but I even found this great web-app that makes everything way easier by duplicating the existing configs:
Another secret of not missing a UI on your VPS server 🖥️

Continuing with the subject, it's definitely possible to install it using Docker 😏 Check out the instructions here.

As a convenient shortcut, it even let you generate a free Let's Encrypt certificate to configure SSL (HTTPS) on the targeted subdomain with just a few clicks!

You might need to sudo systemctl stop nginxduring the acme challenge
⚠️
Just so you know, it is currently not possible to self-host Supabase on Railway because of a limitation: one single volume per service.
Of course, this limitation does not apply to your VPS 🔥

Conclusion

Although getting a VPS for self-hosting many services wasn't initially a calculated move, it turned out to be a pleasant surprise that reshaped all my previous misconceptions for the better. I'm looking forward to renewing my VPS subscription, and gently forget about this abomination (haha)!:

My 2012 Mac mini, on the cat tree, connected with an Ethernet cable, and placed upside down due to a missing screw that might cause the RAM and SSD to fall out 😂