Moving to fly.io

by mark | 13 Aug 2023, 10:41 a.m.

This site used to be hosted on Heroku. I liked it as any changes could be put in via git push heroku master. However, they moved from having a free tier to charging even for very basic web apps. (No one reads this blog so the bandwidth and compute needed are trivial). I didn't mind paying $7 a month for some cloud based compute, until suddenly I did. I thought there must be other services around.

Ended up settling on fly.io. Took an hour or so to figure it out. fly.io still charges if you exceed a free amount of resources, which I won't, because noone reads this. 

Basically what you do is

  • Read the instructions on fly.io about launching an app
  • There is one gotcha: environment variables. Fly uses some different kind of container technology compared to what heroku does, so getting your variable to appear in the right place is different. Fly calls these secrets, but all secrets referenced in config.py need to be a thing called a build secret, otherwise fly complains it cannot see it. 

    Build secrets are documented. I needed quite a few of them for various reasons, so the dockerfile had a lot of them put in and I had to write a short shell script to call fly deploy

    Every secret needs two lines in the docker file, a local file that can be cat with the secret in it (ADD TO IGNORE FILES!!!), and a line in a deployment shell script. 

It's a bit clunkier but to save £60 a year I can deal with it. 

I'm still not quite sure why there needs to be two kinds of secrets. I prefered pushing to git to deploy rather than what fly has as well. 

No comments

Back to all articles