Bye Heroku, hey Fly.io
👋

Bye Heroku, hey Fly.io

Tags
Technology
Description
Migrate datastore for this blog’s comment system
Published
Published November 30, 2022
I still remember the first time I deployed a database backed website with a single command, it completely blows my mind and the tool made it possible was Heroku. Nowadays when talking about containerization, Docker/k8s gets mentioned a lot, but the real pioneer in that space (PAAS) is Heroku, at least to me. It offloads the burden of provisioning (e.g. bins/libs installation), scaling (e.g. load balancing), dealing with security (e.g. tls/ssl termination) and a lot other chores from programmers, so that they only need to focus on building the app. However, Heroku recently (11/28) cancelled its free plan for all customers. As a result, I did a bit research to look for an alternative and came across another great tool - fly.io.

Background

One practical reason I’m looking for a Heroku alternative is that I’m using its Heroku Postgres service. The comment system of this blog is powered by https://github.com/djyde/cusdis thanks to Randy (the creator), self hosted by Vercel (compute) and Heroku Postgres (storage) with a simple comment form widget (iframe) at the bottom of this page. Since it's mostly a quiet blog, the free-tier plan of both services is more than enough for comments.

Migration Guide

Smart move, isn't it?

Migration Steps

Breaking down into 2 parts, 1) Migrating the data to Fly Postgres 2) Exposing to external connections (i.e. DB_URL for above Vercel app to connect).

Migrating the data to Fly Postgres

  1. Provision database app
    1. Data transfer
      1. Verify

        Exposing to external connections

        1. IP allocation
          1. Expose external port
            1. Pull down fly.toml configuration file
              Update above configuration file
          1. Deploy and verify changes

            Wrap up

            By combining IP and public port above, we should be able to get the database url, something that looks like postgres://postgres:<pasword>@<host IPv4 address>:10000/cusdis . Just replace the old url with this new one and test with a few comments, then we should be 🥂.
             
            Caveats
            • Rename. i.e. replace cusdis-db appeared in above commands with your own app-db name